Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-02-27 03:49:06
Exec Total Coverage
Lines: 7971 11650 68.4%
Functions: 68 105 64.8%
Branches: 4975 9878 50.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23
24
25 #include "metadata/sigs/devsig.h.sig"
26 #include "metadata/sigs/compilersig.h.sig"
27 #include "metadata/versionsig.h"
28 #include "base/zc_alleg.h"
29 #include "base/zdefs.h"
30 #include "base/colors.h"
31 #include "tiles.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 //#include "zquest.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "font.h"
38 #include "zc_custom.h"
39 #include "sfx.h"
40 #include "md5.h"
41 #include "ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 int32_t temp_ffscript_version = 0;
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59
60 #ifdef _MSC_VER
61 #define strncasecmp _strnicmp
62 #endif
63
64 #ifndef _AL_MALLOC
65 #define _AL_MALLOC(a) _al_malloc(a)
66 #define _AL_FREE(a) _al_free(a)
67 #endif
68
69 using std::string;
70 using std::pair;
71
72 // extern bool debug;
73 extern int32_t hero_animation_speed; //lower is faster animation
74 extern std::vector<mapscr> TheMaps;
75 extern zcmap *ZCMaps;
76 extern MsgStr *MsgStrings;
77 extern DoorComboSet *DoorComboSets;
78 extern dmap *DMaps;
79 extern newcombo *combobuf;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 29 string zScript;
95 29 std::map<int32_t, script_slot_data > ffcmap;
96 29 std::map<int32_t, script_slot_data > globalmap;
97 29 std::map<int32_t, script_slot_data > genericmap;
98 29 std::map<int32_t, script_slot_data > itemmap;
99 29 std::map<int32_t, script_slot_data > npcmap;
100 29 std::map<int32_t, script_slot_data > ewpnmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
29 std::map<int32_t, script_slot_data > lwpnmap;
102 29 std::map<int32_t, script_slot_data > playermap;
103 29 std::map<int32_t, script_slot_data > dmapmap;
104 29 std::map<int32_t, script_slot_data > screenmap;
105 29 std::map<int32_t, script_slot_data > itemspritemap;
106 29 std::map<int32_t, script_slot_data > comboscriptmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 extern combo_alias combo_aliases[MAXCOMBOALIASES];
129 extern combo_pool combo_pools[MAXCOMBOPOOLS];
130 const char *qst_error[] =
131 {
132 "OK","File not found","Invalid quest file",
133 "Version not supported","Obsolete version",
134 "Missing new data" , /* but let it pass in ZQuest */
135 "Internal error occurred", "Invalid password",
136 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
137 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
138 };
139
140 //for legacy quests -DD
141 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
142 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
143 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
144 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
145 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
146 };
147
148 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
149
150
151 void delete_combo_aliases()
152 {
153 for(int32_t j(0); j<256; j++)
154 {
155 if(combo_aliases[j].combos != NULL)
156 {
157 delete[] combo_aliases[j].combos;
158 combo_aliases[j].combos=NULL;
159 }
160
161 if(combo_aliases[j].csets != NULL)
162 {
163 delete[] combo_aliases[j].csets;
164 combo_aliases[j].csets=NULL;
165 }
166 }
167
168 }
169
170 char *byte_conversion(int32_t number, int32_t format)
171 {
172 static char num_str[40];
173
174 if(format==-1) //auto
175 {
176 format=1; //bytes
177
178 if(number>1024)
179 {
180 format=2; //kilobytes
181 }
182
183 if(number>1024*1024)
184 {
185 format=3; //megabytes
186 }
187
188 if(number>1024*1024*1024)
189 {
190 format=4; //gigabytes (dude, what are you doing?)
191 }
192 }
193
194 switch(format)
195 {
196 case 1: //bytes
197 sprintf(num_str,"%db",number);
198 break;
199
200 case 2: //kilobytes
201 sprintf(num_str,"%.2fk",float(number)/1024);
202 break;
203
204 case 3: //megabytes
205 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
206 break;
207
208 case 4: //gigabytes
209 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
210 break;
211
212 default:
213 exit(1);
214 break;
215 }
216
217 return num_str;
218 }
219
220 406 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
221 {
222 static char num_str1[40];
223 static char num_str2[40];
224 static char num_str[80];
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format1==-1) //auto
227 {
228 406 format1=1; //bytes
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number1>1024)
231 {
232 406 format1=2; //kilobytes
233 406 }
234
235
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 116 times.
406 if(number1>1024*1024)
236 {
237 116 format1=3; //megabytes
238 116 }
239
240
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number1>1024*1024*1024)
241 {
242 format1=4; //gigabytes (dude, what are you doing?)
243 }
244 406 }
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(format2==-1) //auto
247 {
248 406 format2=1; //bytes
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if(number2>1024)
251 {
252 406 format2=2; //kilobytes
253 406 }
254
255
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 377 times.
406 if(number2>1024*1024)
256 {
257 377 format2=3; //megabytes
258 377 }
259
260
1/2
✓ Branch 0 taken 406 times.
✗ Branch 1 not taken.
406 if(number2>1024*1024*1024)
261 {
262 format2=4; //gigabytes (dude, what are you doing?)
263 }
264 406 }
265
266
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
406 switch(format1)
267 {
268 case 1: //bytes
269 sprintf(num_str1,"%db",number1);
270 break;
271
272 case 2: //kilobytes
273 290 sprintf(num_str1,"%.2fk",float(number1)/1024);
274 290 break;
275
276 case 3: //megabytes
277 116 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
278 116 break;
279
280 case 4: //gigabytes
281 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
282 break;
283
284 default:
285 exit(1);
286 break;
287 }
288
289
2/5
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 377 times.
✗ Branch 4 not taken.
406 switch(format2)
290 {
291 case 1: //bytes
292 sprintf(num_str2,"%db",number2);
293 break;
294
295 case 2: //kilobytes
296 29 sprintf(num_str2,"%.2fk",float(number2)/1024);
297 29 break;
298
299 case 3: //megabytes
300 377 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
301 377 break;
302
303 case 4: //gigabytes
304 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
305 break;
306
307 default:
308 exit(1);
309 break;
310 }
311
312 406 sprintf(num_str, "%s/%s", num_str1, num_str2);
313 406 return num_str;
314 }
315
316 char *ordinal(int32_t num)
317 {
318 static const char *ending[4] = {"st","nd","rd","th"};
319 static char ord_str[8];
320
321 char *end;
322 int32_t t=(num%100)/10;
323 int32_t n=num%10;
324
325 if(n>=1 && n<4 && t!=1)
326 end = (char *)ending[n-1];
327 else
328 end = (char *)ending[3];
329
330 sprintf(ord_str,"%d%s",num%10000,end);
331 return ord_str;
332 }
333
334 29 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
335 {
336 int32_t ret;
337 29 *version=0;
338 29 *build=0;
339 29 byte temp_map_count=map_count;
340 byte temp_midi_flags[MIDIFLAGS_SIZE];
341 29 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
342
343 zquestheader tempheader;
344
345
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
346 {
347 return qe_invalid;
348 }
349
350 29 ret=readheader(f, &tempheader, true);
351
352
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(ret)
353 {
354 return ret;
355 }
356
357 29 map_count=temp_map_count;
358 29 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
359 29 *version=tempheader.zelda_version;
360 29 *build=tempheader.build;
361 29 return 0;
362 29 }
363
364
365 29 bool find_section(PACKFILE *f, int32_t section_id_requested)
366 {
367
368
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
369 {
370 return false;
371 }
372
373 int32_t section_id_read;
374 29 bool catchup=false;
375 word dummy;
376 byte tempbyte;
377 char tempbuf[65536];
378
379
380
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id_requested)
381 {
382 case ID_RULES:
383 case ID_STRINGS:
384 case ID_MISC:
385 case ID_TILES:
386 case ID_COMBOS:
387 case ID_CSETS:
388 case ID_MAPS:
389 case ID_DMAPS:
390 case ID_DOORS:
391 case ID_ITEMS:
392 case ID_WEAPONS:
393 case ID_COLORS:
394 case ID_ICONS:
395 case ID_INITDATA:
396 case ID_GUYS:
397 case ID_MIDIS:
398 case ID_CHEATS:
399 29 break;
400
401 default:
402 al_trace("Bad section requested!\n");
403 return false;
404 break;
405 }
406
407 dword section_size;
408
409 //section id
410
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_mgetl(&section_id_read,f,true))
411 {
412 return false;
413 }
414
415
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 while(!pack_feof(f))
416 {
417
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 switch(section_id_read)
418 {
419 case ID_RULES:
420 case ID_STRINGS:
421 case ID_MISC:
422 case ID_TILES:
423 case ID_COMBOS:
424 case ID_CSETS:
425 case ID_MAPS:
426 case ID_DMAPS:
427 case ID_DOORS:
428 case ID_ITEMS:
429 case ID_WEAPONS:
430 case ID_COLORS:
431 case ID_ICONS:
432 case ID_INITDATA:
433 case ID_GUYS:
434 case ID_MIDIS:
435 case ID_CHEATS:
436 29 catchup=false;
437 29 break;
438
439 default:
440 5887 break;
441 }
442
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5916 times.
5916 while(catchup)
445 {
446 //section id
447 section_id_read=(section_id_read<<8);
448
449 if(!p_getc(&tempbyte,f,true))
450 {
451 return false;
452 }
453
454 section_id_read+=tempbyte;
455 }
456
457
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(section_id_read==section_id_requested)
458 {
459 return true;
460 }
461 else
462 {
463 //section version info
464
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
465 {
466 return false;
467 }
468
469
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetw(&dummy,f,true))
470 {
471 return false;
472 }
473
474 //section size
475
1/2
✓ Branch 0 taken 5916 times.
✗ Branch 1 not taken.
5916 if(!p_igetl(&section_size,f,true))
476 {
477 return false;
478 }
479
480 //pack_fseek(f, section_size);
481
2/2
✓ Branch 0 taken 1900515 times.
✓ Branch 1 taken 5916 times.
1906431 while(section_size>65535)
482 {
483 1900515 pfread(tempbuf,65535,f,true);
484 1900515 tempbuf[65535]=0;
485 1900515 section_size-=65535;
486 }
487
488
2/2
✓ Branch 0 taken 5771 times.
✓ Branch 1 taken 145 times.
5916 if(section_size>0)
489 {
490 145 pfread(tempbuf,section_size,f,true);
491 145 tempbuf[section_size]=0;
492 145 }
493 }
494
495 //section id
496
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 5887 times.
5916 if(!p_mgetl(&section_id_read,f,true))
497 {
498 29 return false;
499 }
500 }
501
502 return false;
503 29 }
504
505
506
507
508
509 29 bool valid_zqt(PACKFILE *f)
510 {
511
512 //word tiles_used;
513 //word combos_used;
514 //open the file
515 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f)
517 return false;
518
519 //for now, everything else is valid
520 29 return true;
521
522 /*int16_t version;
523 byte build;
524
525 //read the version and make sure it worked
526 if(!p_igetw(&version,f,true))
527 {
528 goto error;
529 }
530
531 //read the build and make sure it worked
532 if(!p_getc(&build,f,true))
533 goto error;
534
535 //read the tile info and make sure it worked
536 if(!p_igetw(&tiles_used,f,true))
537 {
538 goto error;
539 }
540
541 for (int32_t i=0; i<tiles_used; i++)
542 {
543 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
544 {
545 goto error;
546 }
547 }
548
549 //read the combo info and make sure it worked
550 if(!p_igetw(&combos_used,f,true))
551 {
552 goto error;
553 }
554 for (int32_t i=0; i<combos_used; i++)
555 {
556 if(!pfread(trashbuf,sizeof(newcombo),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the palette info and make sure it worked
563 for (int32_t i=0; i<48; i++)
564 {
565 if(!pfread(trashbuf,newpdTOTAL,f,true))
566 {
567 goto error;
568 }
569 }
570 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
571 {
572 goto error;
573 }
574 for (int32_t i=0; i<MAXLEVELS; i++)
575 {
576 if(!pfread(trashbuf,PALNAMESIZE,f,true))
577 {
578 goto error;
579 }
580 }
581
582 //read the sprite info and make sure it worked
583 for (int32_t i=0; i<MAXITEMS; i++)
584 {
585 if(!pfread(trashbuf,sizeof(itemdata),f,true))
586 {
587 goto error;
588 }
589 }
590
591 for (int32_t i=0; i<MAXWPNS; i++)
592 {
593 if(!pfread(trashbuf,sizeof(wpndata),f,true))
594 {
595 goto error;
596 }
597 }
598
599 //read the triforce pieces info and make sure it worked
600 for (int32_t i=0; i<8; ++i)
601 {
602 if(!p_getc(&trashbuf,f,true))
603 {
604 goto error;
605 }
606 }
607
608
609
610 //read the game icons info and make sure it worked
611 for (int32_t i=0; i<4; ++i)
612 {
613 if(!p_igetw(&trashbuf,f,true))
614 {
615 goto error;
616 }
617 }
618
619 //read the misc colors info and map styles info and make sure it worked
620 if(!pfread(trashbuf,sizeof(zcolors),f,true))
621 {
622 goto error;
623 }
624
625 //read the template screens and make sure it worked
626 byte num_maps;
627 if(!p_getc(&num_maps,f,true))
628 {
629 goto error;
630 }
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f,true))
634 {
635 goto error;
636 }
637 }
638 if (num_maps>1) //dungeon templates
639 {
640 for (int32_t i=0; i<TEMPLATES; i++)
641 {
642 if(!pfread(trashbuf,sizeof(mapscr),f,true))
643 {
644 goto error;
645 }
646 }
647 }
648
649 //yay! it worked! close the file and say everything was ok.
650 pack_fclose(f);
651 return true;
652
653 error:
654 pack_fclose(f);
655 return false;*/
656 29 }
657
658 bool valid_zqt(const char *filename)
659 {
660 PACKFILE *f=NULL;
661 bool isvalid;
662 char deletefilename[1024];
663 deletefilename[0]=0;
664 int32_t error;
665 f=open_quest_file(&error, filename, deletefilename, true, true,false);
666
667 if(!f)
668 {
669 // setPackfilePassword(NULL);
670 return false;
671 }
672
673 isvalid=valid_zqt(f);
674
675 if(deletefilename[0])
676 {
677 delete_file(deletefilename);
678 }
679
680 // setPackfilePassword(NULL);
681 return isvalid;
682 }
683
684 128 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
685 {
686 char tmpfilename[L_tmpnam];
687 128 temp_name(tmpfilename);
688 char percent_done[30];
689 128 int32_t current_method=0;
690
691 PACKFILE *f;
692 128 const char *passwd= encrypted ? datapwd : "";
693
694 // oldquest flag is set when an unencrypted qst file is suspected.
695 128 bool oldquest = false;
696 int32_t ret;
697
698
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(show_progress)
699 {
700 box_start(1, "Loading Quest", lfont, font, true);
701 }
702
703 128 box_out("Loading Quest: ");
704 //if(strncasecmp(filename, "qst.dat", 7)!=0)
705 //int32_t qstdat_str_size = 0;
706 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
707 //{
708 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
709 // else break;
710 //}
711 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
712 128 al_trace("Trying to do strncasecmp() when loading a quest\n");
713 128 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
714 128 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
716
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
717 {
718 128 box_out(filename);
719 128 }
720 else
721 {
722 box_out("new quest"); // Or whatever
723 }
724 128 box_out("...");
725 128 box_eol();
726 128 box_eol();
727
728
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(encrypted)
729 {
730 128 box_out("Decrypting...");
731 128 box_save_x();
732 128 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
733
734
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(ret)
735 {
736
1/3
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3 switch(ret)
737 {
738 case 1:
739 box_out("error.");
740 box_eol();
741 box_end(true);
742 *open_error=qe_notfound;
743 return NULL;
744
745 case 2:
746 box_out("error.");
747 box_eol();
748 box_end(true);
749 *open_error=qe_internal;
750 return NULL;
751 // be sure not to delete tmpfilename now...
752 }
753
754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
755 {
756 3 current_method++;
757 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
758 3 box_out(percent_done);
759 3 box_load_x();
760 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
761 3 }
762
763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret==5) //old encryption?
764 {
765 3 current_method++;
766 3 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
767 3 box_out(percent_done);
768 3 box_load_x();
769 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
770 3 }
771
772
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
773 {
774 current_method++;
775 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
776 box_out(percent_done);
777 box_load_x();
778 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
779 }
780
781
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret==5) //old encryption?
782 {
783 current_method++;
784 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 box_out(percent_done);
786 box_load_x();
787 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
788 }
789
790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(ret)
791 {
792 oldquest = true;
793 passwd="";
794 }
795 3 }
796
797 128 box_out("okay.");
798 128 box_eol();
799 128 }
800 else
801 {
802 oldquest = true;
803 }
804
805 128 box_out("Opening...");
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
807
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!f)
808 {
809 if((compressed==1)&&(errno==EDOM))
810 {
811 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
812 }
813
814 if(!f)
815 {
816 if(!oldquest)
817 {
818 delete_file(tmpfilename);
819 }
820 box_out("error.");
821 box_eol();
822 box_end(true);
823 *open_error=qe_invalid;
824 return NULL;
825 }
826 }
827
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!oldquest)
829 {
830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(deletefilename)
831 128 sprintf(deletefilename, "%s", tmpfilename);
832 128 }
833
834 128 box_out("okay.");
835 128 box_eol();
836
837 128 return f;
838 128 }
839
840 29 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
841 {
842 char *filename;
843 29 PACKFILE *f=NULL;
844 29 int32_t open_error=0;
845 29 deletefilename[0]=0;
846
847 29 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
848 29 strcat(qstdat_string,"#NESQST_NEW_QST");
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
850 {
851 29 filename=(char *)malloc(2048);
852 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
853 29 strcpy(filename, qstdat_string);
854 29 }
855 else
856 {
857 filename=Header->templatepath;
858 }
859
860 29 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(Header->templatepath[0]==0)
863 {
864 29 free(filename);
865 29 }
866
867
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!f)
868 {
869 return NULL;
870 }
871
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(validate)
873 {
874
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!valid_zqt(f))
875 {
876 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
877 pack_fclose(f);
878
879 //setPackfilePassword(NULL);
880 if(deletefilename[0])
881 {
882 delete_file(deletefilename);
883 }
884
885 return NULL;
886 }
887 29 }
888
889 29 return f;
890 29 }
891
892 29 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
893 {
894 29 combosread=false;
895 29 mapsread=false;
896 29 fixffcs=false;
897
898
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 switch(section_id)
899 {
900 case ID_RULES:
901 case ID_STRINGS:
902 case ID_MISC:
903 case ID_TILES:
904 case ID_COMBOS:
905 case ID_CSETS:
906 case ID_MAPS:
907 case ID_DMAPS:
908 case ID_DOORS:
909 case ID_ITEMS:
910 case ID_WEAPONS:
911 case ID_COLORS:
912 case ID_ICONS:
913 case ID_INITDATA:
914 case ID_GUYS:
915 case ID_MIDIS:
916 case ID_CHEATS:
917 case ID_ITEMDROPSETS:
918 case ID_FAVORITES:
919 29 break;
920
921 default:
922 return false;
923 break;
924 }
925
926 int32_t ret;
927 word version, build;
928 29 PACKFILE *f=NULL;
929
930 char deletefilename[1024];
931 29 deletefilename[0]=0;
932
933 //why is this here?
934 /*
935 if(colordata==NULL)
936 return false;
937 */
938
939 //setPackfilePassword(datapwd);
940 29 f=open_quest_template(Header, deletefilename, validate);
941
942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!f) //no file, nothing to delete
943 {
944 // setPackfilePassword(NULL);
945 return false;
946 }
947
948 29 ret=get_version_and_build(f, &version, &build);
949
950
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if(ret||(version==0))
951 {
952 pack_fclose(f);
953
954 if(deletefilename[0])
955 {
956 delete_file(deletefilename);
957 }
958
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!find_section(f, section_id))
964 {
965 29 al_trace("Can't find section!\n");
966 29 pack_fclose(f);
967
968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(deletefilename[0])
969 {
970 29 delete_file(deletefilename);
971 29 }
972
973 //setPackfilePassword(NULL);
974 29 return false;
975 }
976
977 switch(section_id)
978 {
979 case ID_RULES:
980 //rules
981 ret=readrules(f, Header, true);
982 break;
983
984 case ID_STRINGS:
985 //strings
986 ret=readstrings(f, Header, true);
987 break;
988
989 case ID_MISC:
990 //misc data
991 ret=readmisc(f, Header, Misc, true);
992 break;
993
994 case ID_TILES:
995 //tiles
996 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
997 break;
998
999 case ID_COMBOS:
1000 //combos
1001 clear_combos();
1002 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1003 combosread=true;
1004 break;
1005
1006 case ID_COMBOALIASES:
1007 //combos
1008 ret=readcomboaliases(f, Header, version, build, true);
1009 break;
1010
1011 case ID_CSETS:
1012 //color data
1013 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1014 break;
1015
1016 case ID_MAPS:
1017 //maps
1018 ret=readmaps(f, Header, true);
1019 mapsread=true;
1020 break;
1021
1022 case ID_DMAPS:
1023 //dmaps
1024 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1025 break;
1026
1027 case ID_DOORS:
1028 //door combo sets
1029 ret=readdoorcombosets(f, Header, true);
1030 break;
1031
1032 case ID_ITEMS:
1033 //items
1034 ret=readitems(f, version, build, true);
1035 break;
1036
1037 case ID_WEAPONS:
1038 //weapons
1039 ret=readweapons(f, Header, true);
1040 break;
1041
1042 case ID_COLORS:
1043 //misc. colors
1044 ret=readmisccolors(f, Header, Misc, true);
1045 break;
1046
1047 case ID_ICONS:
1048 //game icons
1049 ret=readgameicons(f, Header, Misc, true);
1050 break;
1051
1052 case ID_INITDATA:
1053 //initialization data
1054 ret=readinitdata(f, Header, true);
1055 break;
1056
1057 case ID_GUYS:
1058 //guys
1059 ret=readguys(f, Header, true);
1060 break;
1061
1062 case ID_MIDIS:
1063 //midis
1064 ret=readtunes(f, Header, tunes, true);
1065 break;
1066
1067 case ID_CHEATS:
1068 //cheat codes
1069 ret=readcheatcodes(f, Header, true);
1070 break;
1071
1072 case ID_ITEMDROPSETS:
1073 //item drop sets
1074 // Why is this one commented out?
1075 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1076 break;
1077
1078 case ID_FAVORITES:
1079 // favorite combos and aliases
1080 ret=readfavorites(f, version, build, true);
1081 break;
1082
1083 default:
1084 ret=-1;
1085 break;
1086 }
1087
1088 pack_fclose(f);
1089
1090 if(deletefilename[0])
1091 {
1092 delete_file(deletefilename);
1093 }
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 29 }
1103
1104 bool init_tiles(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate);
1107 }
1108
1109 bool init_combos(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1112 }
1113
1114 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1115 {
1116 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1117 }
1118
1119 99 void init_spritelists()
1120 {
1121
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(FFCore.quest_format[vZelda] < 0x255)
1122 {
1123 77 guys.setMax(255);
1124 77 items.setMax(255);
1125 77 Ewpns.setMax(255);
1126 77 Lwpns.setMax(255);
1127 77 Sitems.setMax(255);
1128 77 chainlinks.setMax(255);
1129 77 decorations.setMax(255);
1130 77 particles.setMax(255);
1131 77 }
1132 else
1133 {
1134 22 guys.setMax(255);
1135 22 items.setMax(255);
1136 22 Ewpns.setMax(255);
1137 22 Lwpns.setMax(255);
1138 22 Sitems.setMax(255);
1139 22 chainlinks.setMax(255);
1140 22 decorations.setMax(255);
1141 22 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1142 }
1143 99 }
1144
1145 29 bool reset_items(bool validate, zquestheader *Header)
1146 {
1147 29 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1148
1149 //Ignore this, but don't remove it
1150 /*
1151 if (ret)
1152 for(int32_t i=0; i<MAXITEMS; i++)
1153 {
1154 reset_itembuf(&itemsbuf[i], i);
1155 }
1156 */
1157
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 29 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1172
1173 for(int32_t i=0; i<WPNCNT; i++)
1174 reset_weaponname(i);
1175
1176 return ret;
1177 }
1178
1179 bool reset_mapstyles(bool validate, miscQdata *Misc)
1180 {
1181 Misc->colors.blueframe_tile = 20044;
1182 Misc->colors.blueframe_cset = 0;
1183 Misc->colors.triforce_tile = 23461;
1184 Misc->colors.triforce_cset = 1;
1185 Misc->colors.triframe_tile = 18752;
1186 Misc->colors.triframe_cset = 1;
1187 Misc->colors.overworld_map_tile = 16990;
1188 Misc->colors.overworld_map_cset = 2;
1189 Misc->colors.HCpieces_tile = 21160;
1190 Misc->colors.HCpieces_cset = 8;
1191 Misc->colors.dungeon_map_tile = 19651;
1192 Misc->colors.dungeon_map_cset = 8;
1193 return true;
1194 }
1195
1196 bool reset_doorcombosets(bool validate, zquestheader *Header)
1197 {
1198 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1199 }
1200
1201 29 int32_t get_qst_buffers()
1202 {
1203 29 memrequested+=(sizeof(mapscr)*MAPSCRS);
1204 29 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1205 29 TheMaps.resize(MAPSCRS);
1206
1207
2/2
✓ Branch 0 taken 3944 times.
✓ Branch 1 taken 29 times.
3973 for(int32_t i(0); i<MAPSCRS; i++)
1208 3944 TheMaps[i].zero_memory();
1209
1210 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1211 29 Z_message("OK\n"); // Allocating map buffer...
1212
1213 29 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1214 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1215
1216
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1217 return 0;
1218
1219 29 Z_message("OK\n");
1220
1221 // Allocating space for all 65535 strings uses up 10.62MB...
1222 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1223 // (Shoelace's "Hero of Dreams" uses 1415.)
1224 // So let's be a bit generous and allow 4096 initially.
1225 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1226 // I tested it and it worked without flaw on 6/6/11. - L.
1227 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1228 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1229 // See https://discord.com/channels/876899628556091432/992984989073416242
1230 29 msg_strings_size = 8192;
1231 29 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1232 29 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1233
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 MsgStrings = new MsgStr[msg_strings_size];
1235
1236 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1237
2/2
✓ Branch 0 taken 237568 times.
✓ Branch 1 taken 29 times.
237597 for(auto q = 0; q < msg_strings_size; ++q)
1238 {
1239 237568 MsgStrings[q].clear();
1240 237568 }
1241 29 Z_message("OK\n"); // Allocating string buffer...
1242
1243 29 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1244 29 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1245
1246
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1247 return 0;
1248
1249 29 Z_message("OK\n"); // Allocating door combo buffer...
1250
1251 29 memrequested+=(sizeof(dmap)*MAXDMAPS);
1252 29 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1253
1254
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1255 return 0;
1256
1257 29 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1258 29 Z_message("OK\n"); // Allocating dmap buffer...
1259
1260 29 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1261 29 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1262
1263
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1264 return 0;
1265
1266 29 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1267 29 Z_message("OK\n"); // Allocating combo buffer...
1268
1269 29 memrequested+=(psTOTAL255);
1270 29 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1271
1272
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1273 return 0;
1274
1275 29 Z_message("OK\n"); // Allocating color data buffer...
1276
1277 29 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1278 29 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1279
1280 29 free_newtilebuf();
1281
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1282 return 0;
1283
1284 29 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1285 //Z_message("Performed memset on tiles\n");
1286 29 clear_tiles(newtilebuf);
1287 //Z_message("Performed clear_tiles()\n");
1288 29 Z_message("OK\n"); // Allocating tile buffer...
1289
1290
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(is_zquest())
1291 {
1292 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1293 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1294
1295 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1296 return 0;
1297
1298 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1299 clear_tiles(grabtilebuf);
1300 Z_message("OK\n"); // Allocating tile grab buffer...
1301 }
1302
1303 29 memrequested+=(100000);
1304 29 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1305
1306
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((trashbuf=(byte*)malloc(100000))==NULL)
1307 return 0;
1308
1309 29 Z_message("OK\n"); // Allocating trash buffer...
1310
1311 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1312 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1313 // fixed by ensuring there's actually itemdata there.
1314 // If you change this, be sure to update del_qst_buffers, too.
1315
1316 29 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1317 29 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1318
1319
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1320 return 0;
1321
1322 29 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1323 29 itemsbuf++;
1324 29 Z_message("OK\n"); // Allocating item buffer...
1325
1326 29 memrequested+=(sizeof(wpndata)*MAXWPNS);
1327 29 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1330 return 0;
1331
1332 29 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1333 29 Z_message("OK\n"); // Allocating weapon buffer...
1334
1335 29 memrequested+=(sizeof(guydata)*MAXGUYS);
1336 29 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1339 return 0;
1340
1341 29 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1342 29 Z_message("OK\n"); // Allocating guy buffer...
1343
1344 29 memrequested+=(sizeof(comboclass)*cMAX);
1345 29 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1346
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1348 return 0;
1349
1350 29 Z_message("OK\n"); // Allocating combo class buffer...
1351
1352 29 return 1;
1353 29 }
1354
1355
1356 29 void free_newtilebuf()
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(newtilebuf)
1359 {
1360 for(int32_t i=0; i<NEWMAXTILES; i++)
1361 if(newtilebuf[i].data)
1362 free(newtilebuf[i].data);
1363
1364 free(newtilebuf);
1365 newtilebuf = 0;
1366 }
1367 29 }
1368
1369 void free_grabtilebuf()
1370 {
1371 if(is_zquest())
1372 {
1373 if(grabtilebuf)
1374 {
1375 for(int32_t i=0; i<NEWMAXTILES; i++)
1376 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1377
1378 free(grabtilebuf);
1379 grabtilebuf = 0;
1380 }
1381 }
1382 }
1383
1384 void del_qst_buffers()
1385 {
1386 al_trace("Cleaning maps. \n");
1387
1388 if(ZCMaps) free(ZCMaps);
1389
1390 if(MsgStrings) delete[] MsgStrings;
1391
1392 if(DoorComboSets) free(DoorComboSets);
1393
1394 if(DMaps) free(DMaps);
1395
1396 if(combobuf) free(combobuf);
1397
1398 if(colordata) free(colordata);
1399
1400 al_trace("Cleaning tile buffers. \n");
1401 free_newtilebuf();
1402 free_grabtilebuf();
1403
1404 al_trace("Cleaning misc. \n");
1405
1406 if(trashbuf) free(trashbuf);
1407
1408 // See get_qst_buffers
1409 if(itemsbuf)
1410 {
1411 itemsbuf--;
1412 free(itemsbuf);
1413 }
1414
1415 if(wpnsbuf) free(wpnsbuf);
1416
1417 if(guysbuf) free(guysbuf);
1418
1419 if(combo_class_buf) free(combo_class_buf);
1420 }
1421
1422 bool init_palnames()
1423 {
1424 // if(palnames==NULL)
1425 // return false;
1426
1427 for(int32_t x=0; x<MAXLEVELS; x++)
1428 {
1429 switch(x)
1430 {
1431 case 0:
1432 sprintf(palnames[x],"Overworld");
1433 break;
1434
1435 case 10:
1436 sprintf(palnames[x],"Caves");
1437 break;
1438
1439 case 11:
1440 sprintf(palnames[x],"Passageways");
1441 break;
1442
1443 default:
1444 sprintf(palnames[x],"%c",0);
1445 break;
1446 }
1447 }
1448
1449 return true;
1450 }
1451
1452 18953 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1453 {
1454 void *p;
1455
1456
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 p = _AL_MALLOC(MAX(size, alloc_size));
1457
1458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18953 times.
18953 if(!p)
1459 {
1460 return NULL;
1461 }
1462
1463
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!pfread(p,size,f,keepdata))
1464 {
1465 _AL_FREE(p);
1466 return NULL;
1467 }
1468
1469
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(pack_ferror(f))
1470 {
1471 _AL_FREE(p);
1472 return NULL;
1473 }
1474
1475 18953 return p;
1476 18953 }
1477
1478 /* read_midi:
1479 * Reads MIDI data from a datafile (this is not the same thing as the
1480 * standard midi file format).
1481 */
1482
1483 1629 static MIDI *read_midi(PACKFILE *f, bool)
1484 {
1485 MIDI *m;
1486 int32_t c;
1487 1629 int16_t divisions=0;
1488 1629 int32_t len=0;
1489
1490 1629 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1491
1492
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!m)
1493 {
1494 return NULL;
1495 }
1496
1497
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1498 {
1499 52128 m->track[c].len = 0;
1500 52128 m->track[c].data = NULL;
1501 52128 }
1502
1503 1629 p_mgetw(&divisions,f,true);
1504 1629 m->divisions=divisions;
1505
1506
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1507 {
1508 52128 p_mgetl(&len,f,true);
1509 52128 m->track[c].len=len;
1510
1511
2/2
✓ Branch 0 taken 33175 times.
✓ Branch 1 taken 18953 times.
52128 if(m->track[c].len > 0)
1512 {
1513 18953 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1514
1515
1/2
✓ Branch 0 taken 18953 times.
✗ Branch 1 not taken.
18953 if(!m->track[c].data)
1516 {
1517 destroy_midi(m);
1518 return NULL;
1519 }
1520 18953 }
1521 52128 }
1522
1523 LOCK_DATA(m, sizeof(MIDI));
1524
1525
2/2
✓ Branch 0 taken 52128 times.
✓ Branch 1 taken 1629 times.
53757 for(c=0; c<MIDI_TRACKS; c++)
1526 {
1527
2/2
✓ Branch 0 taken 18953 times.
✓ Branch 1 taken 33175 times.
52128 if(m->track[c].data)
1528 {
1529 LOCK_DATA(m->track[c].data, m->track[c].len);
1530 18953 }
1531 52128 }
1532
1533 1629 return m;
1534 1629 }
1535
1536 void clear_combo(int32_t i)
1537 {
1538 combobuf[i].clear();
1539 }
1540
1541 void clear_combos()
1542 {
1543 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1544 clear_combo(tmpcounter);
1545 }
1546
1547 void pack_combos()
1548 {
1549 int32_t di = 0;
1550
1551 for(int32_t si=0; si<1024; si+=2)
1552 combobuf[di++] = combobuf[si];
1553
1554 for(; di<1024; di++)
1555 clear_combo(di);
1556 }
1557
1558 99 void reset_tunes(zctune *tune)
1559 {
1560
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1561 {
1562 24948 tune[i].reset();
1563 24948 }
1564 99 }
1565
1566
1567 /*void reset_midi(zcmidi_ *m)
1568 {
1569 m->title[0]=0;
1570 m->loop=1;
1571 m->volume=144;
1572 m->start=0;
1573 m->loop_start=-1;
1574 m->loop_end=-1;
1575 if(m->midi)
1576 {
1577 destroy_midi(m->midi);
1578 }
1579 m->midi=NULL;
1580 }
1581
1582
1583 void reset_midis(zcmidi_ *m)
1584 {
1585 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1586 {
1587 reset_midi(m+i);
1588 }
1589 }
1590 */
1591
1592 void reset_scr(int32_t scr)
1593 {
1594 /*
1595 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1596 for(unsigned i=0; i<sizeof(mapscr); i++)
1597 *(di++) = 0;
1598 TheMaps[scr].valid=mVERSION;
1599 */
1600
1601 TheMaps[scr].zero_memory();
1602 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1603
1604 for(int32_t i=0; i<6; i++)
1605 {
1606 //these will be uncommented later
1607 //TheMaps[scr].layerxsize[i]=16;
1608 //TheMaps[scr].layerysize[i]=11;
1609 TheMaps[scr].layeropacity[i]=255;
1610 }
1611
1612 TheMaps[scr].valid=mVERSION;
1613
1614 }
1615
1616 /* For reference:
1617
1618 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1619 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1620 */
1621
1622 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1623 {
1624 for(int32_t i=0; i<9; i++)
1625 {
1626 for(int32_t j=0; j<6; j++)
1627 {
1628 if(j<4)
1629 {
1630 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1631 {
1632 return false;
1633 }
1634
1635 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1636 {
1637 return false;
1638 }
1639
1640 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1641 {
1642 return false;
1643 }
1644
1645 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1646 {
1647 return false;
1648 }
1649 }
1650
1651 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1652 {
1653 return false;
1654 }
1655
1656 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1657 {
1658 return false;
1659 }
1660
1661 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1662 {
1663 return false;
1664 }
1665
1666 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1667 {
1668 return false;
1669 }
1670 }
1671
1672 if(i<2)
1673 {
1674 if(a.flags[i]!=b.flags[i])
1675 {
1676 return false;
1677 }
1678
1679 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1680 {
1681 return false;
1682 }
1683
1684 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1685 {
1686 return false;
1687 }
1688
1689 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1690 {
1691 return false;
1692 }
1693
1694 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1695 {
1696 return false;
1697 }
1698 }
1699
1700 if(i<3)
1701 {
1702 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1703 {
1704 return false;
1705 }
1706
1707 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1708 {
1709 return false;
1710 }
1711
1712 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1713 {
1714 return false;
1715 }
1716
1717 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1718 {
1719 return false;
1720 }
1721 }
1722
1723 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1724 {
1725 return false;
1726 }
1727
1728 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1729 {
1730 return false;
1731 }
1732 }
1733
1734 return true;
1735 }
1736
1737 int32_t doortranslations_u[9][4]=
1738 {
1739 {37,38,53,54},
1740 {37,38,39,40},
1741 {37,38,55,56},
1742 {37,38,39,40},
1743 {37,38,53,54},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {7,8,23,24},
1747 {7,8,41,42}
1748 };
1749
1750 int32_t doortranslations_d[9][4]=
1751 {
1752 {117,118,133,134},
1753 {135,136,133,134},
1754 {119,120,133,134},
1755 {135,136,133,134},
1756 {117,118,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {151,152,167,168},
1760 {137,138,167,168},
1761 };
1762
1763 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1764 int32_t doortranslations_l[9][6]=
1765 {
1766 {66,67,82,83,98,99},
1767 {66,68,82,84,98,100},
1768 {66,69,82,85,98,101},
1769 {66,68,82,84,98,100},
1770 {66,67,82,83,98,99},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {64,65,80,81,96,97},
1774 {64,65,80,114,96,97},
1775 };
1776
1777 int32_t doortranslations_r[9][6]=
1778 {
1779
1780 {76,77,92,93,108,109},
1781 {75,77,91,93,107,109},
1782 {74,77,90,93,106,109},
1783 {75,77,91,93,107,109},
1784 {76,77,92,93,108,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {78,79,94,95,110,111},
1788 {78,79,125,95,110,111},
1789 };
1790
1791 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1792 {
1793 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1794 }
1795
1796 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1797 {
1798 //these are here to bypass compiler warnings about unused arguments
1799 map=map;
1800 scr=scr;
1801 pos=pos;
1802
1803 //what does this function do?
1804 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1805 return 2;
1806 }
1807
1808 int32_t MakeDoors(int32_t map, int32_t scr)
1809 {
1810 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1811 {
1812 return 0;
1813 }
1814
1815 DoorComboSet tempdcs;
1816 memset(&tempdcs, 0, sizeof(DoorComboSet));
1817
1818 //up
1819 for(int32_t i=0; i<9; i++)
1820 {
1821 for(int32_t j=0; j<4; j++)
1822 {
1823 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1824 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1825 }
1826 }
1827
1828 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1829 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1830 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1831 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1832 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1833 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1834
1835 //down
1836 for(int32_t i=0; i<9; i++)
1837 {
1838 for(int32_t j=0; j<4; j++)
1839 {
1840 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1841 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1842 }
1843 }
1844
1845 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1846
1847 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1848 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1849 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1850 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1851 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1852
1853 //left
1854 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1855 for(int32_t i=0; i<9; i++)
1856 {
1857 for(int32_t j=0; j<6; j++)
1858 {
1859 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1860 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1861 }
1862 }
1863
1864 for(int32_t j=0; j>6; j++)
1865 {
1866 if((j!=2)&&(j!=3))
1867 {
1868 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1869 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1870 }
1871 }
1872
1873 tempdcs.bombdoorcombo_l[0]=0;
1874 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1875 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1876 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1877 tempdcs.bombdoorcombo_l[2]=0;
1878 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1879 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1880 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1881
1882 //right
1883 for(int32_t i=0; i<9; i++)
1884 {
1885 for(int32_t j=0; j<6; j++)
1886 {
1887 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1888 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1889 }
1890 }
1891
1892 for(int32_t j=0; j>6; j++)
1893 {
1894 if((j!=2)&&(j!=3))
1895 {
1896 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1897 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1898 }
1899 }
1900
1901 tempdcs.bombdoorcombo_r[0]=0;
1902 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1903 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1904 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1905 tempdcs.bombdoorcombo_r[2]=0;
1906 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1907 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1908 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1909
1910 int32_t k;
1911
1912 for(k=0; k<door_combo_set_count; k++)
1913 {
1914 if(DoorComboSets[k]==tempdcs)
1915 {
1916 break;
1917 }
1918 }
1919
1920 if(k==door_combo_set_count)
1921 {
1922 DoorComboSets[k]=tempdcs;
1923 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1924 ++door_combo_set_count;
1925 }
1926
1927 return k;
1928 /*
1929 doorcombo_u[9][4];
1930 doorcset_u[9][4];
1931 doorcombo_d[9][4];
1932 doorcset_d[9][4];
1933 doorcombo_l[9][6];
1934 doorcset_l[9][6];
1935 doorcombo_r[9][6];
1936 doorcset_r[9][6];
1937 bombdoorcombo_u[2];
1938 bombdoorcset_u[2];
1939 bombdoorcombo_d[2];
1940 bombdoorcset_d[2];
1941 bombdoorcombo_l[3];
1942 bombdoorcset_l[3];
1943 bombdoorcombo_r[3];
1944 bombdoorcset_r[3];
1945 walkthroughcombo[4];
1946 walkthroughcset[4];
1947 */
1948 }
1949
1950 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1951 {
1952 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1953 }
1954
1955 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1956 {
1957
1958 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1959 }
1960
1961 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1962 {
1963 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1964 }
1965
1966
1967 3 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1968 {
1969 char temp_pwd[30];
1970 3 memset(temp_pwd,0,30);
1971
1972
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(pwdkey!=0)
1973 {
1974 3 memcpy(temp_pwd,encrypted_pwd,30);
1975 3 temp_pwd[29]=0;
1976
1977
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 3 times.
93 for(int32_t i=0; i<30; i++)
1978 {
1979 90 temp_pwd[i] -= pwdkey;
1980 90 int32_t t=pwdkey>>15;
1981 90 pwdkey = (pwdkey<<1)+t;
1982 90 }
1983 3 }
1984
1985 3 memcpy(pwd,temp_pwd,30);
1986 3 }
1987
1988
1989
1990 bool check_questpwd(zquestheader *Header, char *pwd)
1991 {
1992 #if DEVLEVEL > 3
1993 return true;
1994 #endif
1995
1996 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
1997 cvs_MD5Context ctx;
1998 uint8_t md5sum[16];
1999
2000 cvs_MD5Init(&ctx);
2001 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2002 cvs_MD5Final(md5sum, &ctx);
2003
2004 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2005
2006 }
2007
2008 94 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2009 {
2010 94 zprint2("\n");
2011 94 zprint2("[ZQUEST CREATOR METADATA]\n");
2012
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(qst_num < moduledata.max_quest_files)
2013 zprint2("Loading module quest %d\n", qst_num+1);
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(path) zprint2("Loading '%s'\n", path);
2015
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( tempheader.new_version_id_main > 0 )
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(tempheader.new_version_id_fourth > 0)
2018 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2019 tempheader.new_version_id_main,tempheader.new_version_id_second,
2020 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2021 94 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2022 94 tempheader.new_version_id_main,tempheader.new_version_id_second,
2023 94 tempheader.new_version_id_third);
2024 94 }
2025 else
2026 {
2027 switch ( tempheader.zelda_version )
2028 {
2029 case 0x255:
2030 {
2031 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2032 break;
2033 }
2034 case 0x254:
2035 {
2036 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2037 break;
2038 }
2039 case 0x250:
2040 {
2041 switch(tempheader.build)
2042 {
2043 case 19:
2044 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2045 case 20:
2046 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2047 case 21:
2048 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2049 case 22:
2050 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2051 case 23:
2052 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2053 case 24:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2055 case 25:
2056 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2057 case 26:
2058 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2059 case 27:
2060 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2061 case 28:
2062 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2063 case 29:
2064 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2065 case 30:
2066 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2067 case 31:
2068 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2069 case 32:
2070 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2071 case 33:
2072 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2073 default:
2074 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2075
2076 }
2077 break;
2078 }
2079
2080 case 0x211:
2081 {
2082 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2083 }
2084 case 0x210:
2085 {
2086 zprint2("Last saved in ZQuest Version: 2.10.x");
2087 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2088 break;
2089 }
2090 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2091 case 0x193:
2092 {
2093 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2094 }
2095 case 0x192:
2096 {
2097 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2098 }
2099 case 0x190:
2100 {
2101 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2102 }
2103 case 0x184:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2106 }
2107 case 0x183:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2110 }
2111 case 0x180:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 default:
2116 {
2117 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2118 }
2119 */
2120 }
2121 }
2122
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
94 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2123 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2124 77 else zprint2("\n");
2125
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2126
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2127
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2128
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2130
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 17 times.
94 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2131 94 zprint2("\n");
2132 94 }
2133
2134 128 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2135 {
2136 int32_t dummy;
2137 zquestheader tempheader;
2138 char dummybuf[80];
2139 byte temp_map_count;
2140 byte temp_midi_flags[MIDIFLAGS_SIZE];
2141 word version;
2142 char temp_pwd[30], temp_pwd2[30];
2143 int16_t temp_pwdkey;
2144 cvs_MD5Context ctx;
2145 128 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2146 128 memset(&tempheader, 0, sizeof(tempheader));
2147 128 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2148
2149
2150
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2152 {
2153 Z_message("Unable to read header string\n");
2154 return qe_invalid;
2155 }
2156
2157 // check header
2158
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2159 {
2160 if(strcmp(tempheader.id_str,QH_IDSTR))
2161 {
2162 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2163 return qe_invalid;
2164 }
2165 }
2166
2167 128 int32_t templatepath_len=0;
2168
2169 128 tempheader.external_zinfo = false;
2170 128 read_zinfo = false;
2171
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2172 {
2173 byte padding;
2174
2175 if(!p_getc(&padding,f,true))
2176 {
2177 return qe_invalid;
2178 }
2179
2180 if(!p_igetw(&tempheader.zelda_version,f,true))
2181 {
2182 return qe_invalid;
2183 }
2184
2185 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2186
2187 if(tempheader.zelda_version > ZELDA_VERSION)
2188 {
2189 return qe_version;
2190 }
2191
2192 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2193
2194 if(strcmp(tempheader.id_str,QH_IDSTR))
2195 {
2196 return qe_invalid;
2197 }
2198
2199 if(bad_version(tempheader.zelda_version))
2200 {
2201 return qe_obsolete;
2202 }
2203
2204 if(!p_igetw(&tempheader.internal,f,true))
2205 {
2206 return qe_invalid;
2207 }
2208
2209 if(!p_getc(&tempheader.quest_number,f,true))
2210 {
2211 return qe_invalid;
2212 }
2213
2214 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2215
2216 if(!pfread(&quest_rules[0],2,f,true))
2217 {
2218 return qe_invalid;
2219 }
2220
2221 if(!p_getc(&temp_map_count,f,true))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 FFCore.quest_format[qMapCount] = temp_map_count;
2227
2228 if(!p_getc(&tempheader.old_str_count,f,true))
2229 {
2230 return qe_invalid;
2231 }
2232
2233 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2234 {
2235 return qe_invalid;
2236 }
2237
2238 if(!pfread(temp_midi_flags,4,f,true))
2239 {
2240 return qe_invalid;
2241 }
2242
2243 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2244 {
2245 return qe_invalid;
2246 }
2247
2248 if(!pfread(dummybuf,14,f,true))
2249 {
2250 return qe_invalid;
2251 }
2252
2253 if(!pfread(&quest_rules[2],2,f,true))
2254 {
2255 return qe_invalid;
2256 }
2257
2258 if(!p_getc(&dummybuf,f,true))
2259 {
2260 return qe_invalid;
2261 }
2262
2263 if(!pfread(tempheader.version,9,f,true))
2264 {
2265 return qe_invalid;
2266 }
2267
2268 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2269 {
2270 return qe_invalid;
2271 }
2272 // These fields are expected to end in null bytes!
2273 tempheader.title[sizeof(tempheader.title)-1] = 0;
2274
2275 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2276 {
2277 return qe_invalid;
2278 }
2279 tempheader.author[sizeof(tempheader.author)-1] = 0;
2280
2281 if(!p_getc(&padding,f,true))
2282 {
2283 return qe_invalid;
2284 }
2285
2286 if(!p_igetw(&temp_pwdkey,f,true))
2287 {
2288 return qe_invalid;
2289 }
2290
2291 if(!pfread(temp_pwd,30,f,true))
2292 {
2293 return qe_invalid;
2294 }
2295
2296 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2297 cvs_MD5Init(&ctx);
2298 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2299 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2300
2301 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2302 {
2303 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2304 // Not anymore...
2305 memset(tempheader.minver,0,17);
2306 tempheader.build=0;
2307 tempheader.use_keyfile=0;
2308 memset(tempheader.old_foo, 0, 9);
2309 }
2310 else
2311 {
2312 if(!pfread(tempheader.minver,9,f,true))
2313 {
2314 return qe_invalid;
2315 }
2316
2317 if(!p_getc(&tempheader.build,f,true))
2318 {
2319 return qe_invalid;
2320 }
2321
2322 FFCore.quest_format[vBuild] = tempheader.build;
2323
2324 if(!p_getc(&tempheader.use_keyfile,f,true))
2325 {
2326 return qe_invalid;
2327 }
2328
2329 if(!pfread(dummybuf,9,f,true))
2330 {
2331 return qe_invalid;
2332 }
2333 } // starting at minver
2334
2335 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2336 {
2337 memset(&quest_rules[4],0,16); // word rules3..rules10
2338 }
2339 else
2340 {
2341 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2342 {
2343 return qe_invalid; // starting at rules3
2344 }
2345
2346 if(tempheader.zelda_version <= 0x190)
2347 {
2348 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2349 }
2350 }
2351
2352 if((tempheader.zelda_version < 0x192)||
2353 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2354 {
2355 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2356 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2357 }
2358
2359 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2360 {
2361 byte *mf=temp_midi_flags;
2362
2363 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2364 {
2365 mf=(byte*)dummybuf;
2366 }
2367
2368 if(!pfread(mf,32,f,true)) // read new header additions
2369 {
2370 return qe_invalid; // starting at foo2
2371 }
2372
2373 if(!pfread(dummybuf,18,f,true)) // read new header additions
2374 {
2375 return qe_invalid; // starting at foo2
2376 }
2377 }
2378
2379 if((tempheader.zelda_version < 0x192)||
2380 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2381 {
2382 memset(tempheader.templatepath,0,2048);
2383 }
2384 else
2385 {
2386 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2387 {
2388 return qe_invalid;
2389 }
2390 }
2391
2392 if((tempheader.zelda_version < 0x192)||
2393 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2394 {
2395 tempheader.use_keyfile=0;
2396 }
2397 }
2398 else
2399 {
2400 //section id
2401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_mgetl(&dummy,f,true))
2402 {
2403 return qe_invalid;
2404 }
2405
2406 //section version info
2407
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&version,f,true))
2408 {
2409 return qe_invalid;
2410 }
2411
2412 128 FFCore.quest_format[vHeader] = version;
2413
2414
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&dummy,f,true))
2415 {
2416 return qe_invalid;
2417 }
2418
2419 //section size
2420
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetl(&dummy,f,true))
2421 {
2422 return qe_invalid;
2423 }
2424
2425 //finally... section data
2426
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.zelda_version,f,true))
2427 {
2428 return qe_invalid;
2429 }
2430
2431 128 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2432
2433 //do some quick checking...
2434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(tempheader.zelda_version > ZELDA_VERSION)
2435 {
2436 return qe_version;
2437 }
2438
2439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2440 {
2441 return qe_invalid;
2442 }
2443
2444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(bad_version(tempheader.zelda_version))
2445 {
2446 return qe_obsolete;
2447 }
2448
2449
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.build,f,true))
2450 {
2451 return qe_invalid;
2452 }
2453
2454 128 FFCore.quest_format[vBuild] = tempheader.build;
2455
2456
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 125 times.
128 if(version<3)
2457 {
2458
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!pfread(temp_pwd,30,f,true))
2459 {
2460 return qe_invalid;
2461 }
2462
2463
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_pwdkey,f,true))
2464 {
2465 return qe_invalid;
2466 }
2467
2468 3 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2469 3 cvs_MD5Init(&ctx);
2470 3 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2471 3 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2472 3 }
2473 else
2474 {
2475
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2476 {
2477 return qe_invalid;
2478 }
2479 }
2480
2481
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_igetw(&tempheader.internal,f,true))
2482 {
2483 return qe_invalid;
2484 }
2485
2486
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.quest_number,f,true))
2487 {
2488 return qe_invalid;
2489 }
2490
2491 128 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2492
2493 128 size_t versz = version < 8 ? 9 : 16;
2494
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.version,versz,f,true))
2495 {
2496 return qe_invalid;
2497 }
2498
2499 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2500 //needs to be copied as char[9] or stored as a s.str
2501
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.minver,versz,f,true))
2502 {
2503 return qe_invalid;
2504 }
2505
2506 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2507
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2508 {
2509 return qe_invalid;
2510 }
2511 128 tempheader.title[sizeof(tempheader.title)-1] = 0;
2512
2513
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2514 {
2515 return qe_invalid;
2516 }
2517 128 tempheader.author[sizeof(tempheader.author)-1] = 0;
2518
2519
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.use_keyfile,f,true))
2520 {
2521 return qe_invalid;
2522 }
2523
2524 /*
2525 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2526 {
2527 return qe_invalid;
2528 }
2529 */
2530
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2531 {
2532 return qe_invalid;
2533 }
2534
2535
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(&dummybuf,4,f,true))
2536 {
2537 return qe_invalid;
2538 }
2539
2540
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2541 {
2542 return qe_invalid;
2543 }
2544
2545
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(dummybuf,14,f,true))
2546 {
2547 return qe_invalid;
2548 }
2549
2550 128 templatepath_len=sizeof(tempheader.templatepath);
2551
2552
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 3 times.
128 if(version==1)
2553 {
2554 3 templatepath_len=280;
2555 3 }
2556
2557
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2558 {
2559 return qe_invalid;
2560 }
2561
2562
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_map_count,f,true))
2563 {
2564 return qe_invalid;
2565 }
2566
2567
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version>=4)
2568 {
2569
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2594 {
2595 return qe_invalid;
2596 }
2597
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2602 {
2603 return qe_invalid;
2604 }
2605
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2606 {
2607 return qe_invalid;
2608 }
2609
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2610 {
2611 return qe_invalid;
2612 }
2613
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2618 {
2619 return qe_invalid;
2620 }
2621
2622
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_devsig,256,f,true))
2623 {
2624 return qe_invalid;
2625 }
2626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2627 strcpy(tempheader.new_version_devsig, "EmilyV99");
2628
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilername,256,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.product_name,1024,f,true))
2637 {
2638 return qe_invalid;
2639 }
2640
2641
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&tempheader.compilerid,f,true))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2658 {
2659 return qe_invalid;
2660 }
2661
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_igetw(&tempheader.developerid,f,true))
2662 {
2663 return qe_invalid;
2664 }
2665
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2666 {
2667 return qe_invalid;
2668 }
2669
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_datestamp,256,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(!pfread(tempheader.build_timestamp,256,f,true))
2674 {
2675 return qe_invalid;
2676 }
2677 51 }
2678 else // <4
2679 {
2680 77 tempheader.new_version_id_main = 0;
2681 77 tempheader.new_version_id_second = 0;
2682 77 tempheader.new_version_id_third = 0;
2683 77 tempheader.new_version_id_fourth = 0;
2684 77 tempheader.new_version_id_alpha = 0;
2685 77 tempheader.new_version_id_beta = 0;
2686 77 tempheader.new_version_id_gamma = 0;
2687 77 tempheader.new_version_id_release = 0;
2688 77 tempheader.new_version_id_date_year = 0;
2689 77 tempheader.new_version_id_date_month = 0;
2690 77 tempheader.new_version_id_date_day = 0;
2691 77 tempheader.new_version_id_date_hour = 0;
2692 77 tempheader.new_version_id_date_minute = 0;
2693
2694 77 memset(tempheader.new_version_devsig, 0, 256);
2695 77 memset(tempheader.new_version_compilername, 0, 256);
2696 77 memset(tempheader.new_version_compilerversion, 0, 256);
2697 77 memset(tempheader.product_name, 0, 1024);
2698 77 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2699
2700 77 tempheader.compilerid = 0;
2701 77 tempheader.compilerversionnumber_first = 0;
2702 77 tempheader.compilerversionnumber_second = 0;
2703 77 tempheader.compilerversionnumber_third = 0;
2704 77 tempheader.compilerversionnumber_fourth = 0;
2705 77 tempheader.developerid = 0;
2706
2707 77 memset(tempheader.made_in_module_name, 0, 1024);
2708 77 memset(tempheader.build_datestamp, 0, 256);
2709 77 memset(tempheader.build_timestamp, 0, 256);
2710 }
2711
2712
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if ( version >= 5 )
2713 {
2714
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!pfread(tempheader.build_timezone,6,f,true))
2715 {
2716 return qe_invalid;
2717 }
2718 51 }
2719 else // < 5
2720 {
2721 77 memset(tempheader.build_timezone, 0, 6);
2722 }
2723
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
128 if ( version >= 6 )
2724 {
2725 byte b;
2726
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&b,f,true))
2727 {
2728 return qe_invalid;
2729 }
2730 51 tempheader.external_zinfo = b?true:false;
2731 51 read_zinfo = true;
2732 51 }
2733
2734
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 77 times.
128 if(version >= 7)
2735 {
2736
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2737 {
2738 return qe_invalid;
2739 }
2740 51 }
2741 else
2742 {
2743 77 tempheader.new_version_is_nightly = false;
2744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(tempheader.zelda_version < 0x255)
2745 {
2746
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
77 switch(tempheader.zelda_version)
2747 {
2748 case 0x254:
2749 tempheader.new_version_id_main = 2;
2750 tempheader.new_version_id_second = 54;
2751 break;
2752 case 0x250:
2753
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
74 switch(tempheader.build)
2754 {
2755 case 19:
2756 tempheader.new_version_id_main = 2;
2757 tempheader.new_version_id_second = 50;
2758 tempheader.new_version_id_gamma = 1;
2759 break;
2760 case 20:
2761 tempheader.new_version_id_main = 2;
2762 tempheader.new_version_id_second = 50;
2763 tempheader.new_version_id_gamma = 2;
2764 break;
2765 case 21:
2766 tempheader.new_version_id_main = 2;
2767 tempheader.new_version_id_second = 50;
2768 tempheader.new_version_id_gamma = 3;
2769 break;
2770 case 22:
2771 tempheader.new_version_id_main = 2;
2772 tempheader.new_version_id_second = 50;
2773 tempheader.new_version_id_gamma = 4;
2774 break;
2775 case 23:
2776 tempheader.new_version_id_main = 2;
2777 tempheader.new_version_id_second = 50;
2778 tempheader.new_version_id_gamma = 5;
2779 break;
2780 case 24:
2781 22 tempheader.new_version_id_main = 2;
2782 22 tempheader.new_version_id_second = 50;
2783 22 tempheader.new_version_id_release = -1;
2784 22 break;
2785 case 25:
2786 tempheader.new_version_id_main = 2;
2787 tempheader.new_version_id_second = 50;
2788 tempheader.new_version_id_third = 1;
2789 tempheader.new_version_id_gamma = 1;
2790 break;
2791 case 26:
2792 tempheader.new_version_id_main = 2;
2793 tempheader.new_version_id_second = 50;
2794 tempheader.new_version_id_third = 1;
2795 tempheader.new_version_id_gamma = 2;
2796 break;
2797 case 27:
2798 tempheader.new_version_id_main = 2;
2799 tempheader.new_version_id_second = 50;
2800 tempheader.new_version_id_third = 1;
2801 tempheader.new_version_id_gamma = 3;
2802 break;
2803 case 28:
2804 5 tempheader.new_version_id_main = 2;
2805 5 tempheader.new_version_id_second = 50;
2806 5 tempheader.new_version_id_third = 1;
2807 5 tempheader.new_version_id_release = -1;
2808 5 break;
2809 case 29:
2810 24 tempheader.new_version_id_main = 2;
2811 24 tempheader.new_version_id_second = 50;
2812 24 tempheader.new_version_id_third = 2;
2813 24 tempheader.new_version_id_release = -1;
2814 24 break;
2815 case 30:
2816 tempheader.new_version_id_main = 2;
2817 tempheader.new_version_id_second = 50;
2818 tempheader.new_version_id_third = 3;
2819 tempheader.new_version_id_gamma = 1;
2820 break;
2821 case 31:
2822 15 tempheader.new_version_id_main = 2;
2823 15 tempheader.new_version_id_second = 53;
2824 15 tempheader.new_version_id_gamma = -1;
2825 15 break;
2826 case 32:
2827 8 tempheader.new_version_id_main = 2;
2828 8 tempheader.new_version_id_second = 53;
2829 8 tempheader.new_version_id_release = -1;
2830 8 break;
2831 case 33:
2832 tempheader.new_version_id_main = 2;
2833 tempheader.new_version_id_second = 53;
2834 tempheader.new_version_id_third = 1;
2835 break;
2836 }
2837 74 break;
2838
2839 case 0x211:
2840 tempheader.new_version_id_main = 2;
2841 tempheader.new_version_id_second = 11;
2842 tempheader.new_version_id_beta = tempheader.build;
2843 break;
2844 case 0x210:
2845 3 tempheader.new_version_id_main = 2;
2846 3 tempheader.new_version_id_second = 10;
2847 3 tempheader.new_version_id_beta = tempheader.build;
2848 3 break;
2849 }
2850 77 }
2851 }
2852
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
128 if(printmetadata || __isZQuest)
2853 {
2854 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2855 }
2856 }
2857
2858 //{ Version Warning
2859 128 int32_t vercmp = tempheader.compareVer();
2860 128 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2861 128 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2862
4/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
179 if(vercmp > 0 || (!vercmp &&
2863
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 (astatecmp > 0 || (!astatecmp &&
2864 51 avercmp > 0))))
2865 {
2866 bool r = true;
2867 if(loadquest_report)
2868 {
2869 enter_sys_pal();
2870 AlertDialog("Quest saved in newer version",
2871 "This quest was last saved in a newer version of ZQuest."
2872 " Attempting to load this quest may not work correctly; to"
2873 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2874 "\n\nWould you like to continue loading anyway? (Not recommended)",
2875 [&](bool ret,bool)
2876 {
2877 r = ret;
2878 }).show();
2879 exit_sys_pal();
2880 }
2881 if(!r)
2882 return qe_silenterr;
2883 }
2884
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 else if(tempheader.compareDate() > 0)
2885 {
2886 bool r = true;
2887 if(loadquest_report)
2888 {
2889 enter_sys_pal();
2890 AlertDialog("Quest saved in newer build",
2891 "This quest was last saved in a newer build of ZQuest, and may have"
2892 " issues loading in this build."
2893 "\n\nWould you like to continue loading anyway?",
2894 [&](bool ret,bool)
2895 {
2896 r = ret;
2897 }).show();
2898 exit_sys_pal();
2899 }
2900 if(!r)
2901 return qe_silenterr;
2902 }
2903 //}
2904
2905 128 read_ext_zinfo = tempheader.external_zinfo;
2906
2907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(keepdata==true)
2908 {
2909 128 memcpy(Header, &tempheader, sizeof(tempheader));
2910 128 map_count=temp_map_count;
2911 128 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2912 128 }
2913
2914 128 return 0;
2915 128 }
2916
2917 99 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2918 {
2919 int32_t dummy;
2920 zquestheader tempheader;
2921 99 word s_version=0;
2922 99 dword compatrule_version=0;
2923
2924 99 memcpy(&tempheader, Header, sizeof(tempheader));
2925
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(tempheader.zelda_version >= 0x193)
2927 {
2928 //section version info
2929
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
2930 {
2931 return qe_invalid;
2932 }
2933
2934 99 FFCore.quest_format[vRules] = s_version;
2935
2936
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
2937 {
2938 return qe_invalid;
2939 }
2940
2941
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version > 16)
2942 {
2943
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&compatrule_version,f,true))
2944 {
2945 return qe_invalid;
2946 }
2947 22 }
2948 99 FFCore.quest_format[vCompatRule] = compatrule_version;
2949
2950 //section size
2951
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
2952 {
2953 return qe_invalid;
2954 }
2955
2956
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if ( s_version < 15 )
2957 {
2958 //finally... section data
2959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2960 {
2961 return qe_invalid;
2962 }
2963 77 }
2964 else
2965 {
2966
2967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2968 {
2969 return qe_invalid;
2970 }
2971
2972 }
2973 99 }
2974
2975 //al_trace("Rules version %d\n", s_version);
2976 //{ bunch of compat stuff
2977 99 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2978
2979
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
2980 {
2981 3 set_bit(quest_rules,14,0);
2982 3 set_bit(quest_rules,27,0);
2983 3 set_bit(quest_rules,28,0);
2984 3 set_bit(quest_rules,29,0);
2985 3 set_bit(quest_rules,30,0);
2986 3 set_bit(quest_rules,32,0);
2987 3 set_bit(quest_rules,36,0);
2988 3 set_bit(quest_rules,49,0);
2989 3 set_bit(quest_rules,50,0);
2990 3 set_bit(quest_rules,51,0);
2991 3 set_bit(quest_rules,68,0);
2992 3 set_bit(quest_rules,75,0);
2993 3 set_bit(quest_rules,76,0);
2994 3 set_bit(quest_rules,98,0);
2995 3 set_bit(quest_rules,110,0);
2996 3 set_bit(quest_rules,113,0);
2997 3 set_bit(quest_rules,116,0);
2998 3 set_bit(quest_rules,102,0);
2999 3 set_bit(quest_rules,132,0);
3000 3 }
3001
3002 //Now, do any updates...
3003
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3004 {
3005 3 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3006 3 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3007 3 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3008 3 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3009 3 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3010 3 }
3011
3012
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3013 {
3014 set_bit(quest_rules,qr_WALLFLIERS,1);
3015 }
3016
3017
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3018 {
3019 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3020 }
3021
3022
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3023 {
3024 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3025 }
3026
3027
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3028 {
3029 3 set_bit(quest_rules,qr_ARROWCLIP,1);
3030 3 }
3031
3032
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3033 {
3034 3 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3035 3 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3036 3 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3037 3 }
3038
3039
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version <= 0x210)
3040 {
3041 3 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3042 3 set_bit(quest_rules,qr_210_WARPRETURN,1);
3043 3 }
3044
3045 //might not be correct
3046
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x210)
3047 {
3048 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3049 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3050 }
3051
3052
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x211)
3053 {
3054 3 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3055 3 }
3056
3057
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3058 {
3059 set_bit(quest_rules, qr_192b163_WARP,1);
3060 }
3061
3062
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version == 0x210)
3063 {
3064 3 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3065 3 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3066 3 }
3067
3068
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3069 {
3070 3 set_bit(quest_rules, qr_OLDPICKUP,1);
3071 3 }
3072
3073
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3074 {
3075 3 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3076 3 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3077 3 }
3078
3079
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3080 {
3081 3 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3082 3 }
3083
3084
4/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 22 times.
99 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3085 {
3086 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3087 22 }
3088
3089
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3090 {
3091 3 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3092 3 }
3093
3094
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3095 {
3096 3 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3097 3 }
3098
3099
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3100 {
3101 25 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3102 25 }
3103
3104
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3105 {
3106 25 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3107 25 }
3108
3109 //Bombchu fix.
3110
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if(tempheader.zelda_version == 0x250)
3111 {
3112
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 22 times.
74 if ( tempheader.build == 24 ) //2.50.0
3113 {
3114 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3115 22 }
3116
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5 times.
74 if ( tempheader.build == 28 ) //2.50.1
3117 {
3118 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3119 5 }
3120
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
74 if ( tempheader.build == 29 ) //2.50.2
3121 {
3122 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3123 24 }
3124
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( tempheader.build == 30 ) //2.50.3RC1
3125 {
3126 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3127 }
3128 74 }
3129
3130
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3131 {
3132 // qr_OFFSETEWPNCOLLISIONFIX
3133 // All 'official' quests need this disabled.
3134 // All 2.10 and lower quests need this enabled to preseve compatability.
3135 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3136
3137 //~Gleeok
3138 30 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3139
3140 // Broke in build 695
3141
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
30 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3142 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3143 30 }
3144
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (tempheader.zelda_version <= 0x190)
3145 {
3146 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3147 }
3148
7/10
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 22 times.
99 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3149 {
3150 77 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3151 77 }
3152
3153
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3154 {
3155 3 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3156 3 }
3157
3158
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3159 {
3160 77 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3161 77 }
3162
3163
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( tempheader.zelda_version < 0x250 )
3164 {
3165 3 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3166 3 }
3167
3168
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 3)
3169 {
3170 3 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3171 3 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3172 3 }
3173
3174
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<4)
3175 {
3176 3 set_bit(quest_rules,10,0);
3177 3 }
3178
3179
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
3180 {
3181 3 set_bit(quest_rules,27,0);
3182 3 }
3183
3184
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<6)
3185 {
3186 3 set_bit(quest_rules,46,0);
3187 3 }
3188
3189
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<7) // January 2008
3190 {
3191 3 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3192 3 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3193 3 }
3194
3195
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version<8)
3196 {
3197 3 set_bit(quest_rules, 12, 0);
3198 3 }
3199 else
3200 {
3201 96 set_bit(deprecated_rules, 12, 0);
3202 }
3203
3204
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<9) // October 2008
3205 {
3206 3 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3207 3 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3208 3 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3209 3 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3210 3 }
3211
3212
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<10) // December 2008
3213 {
3214 3 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3215 3 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3216 3 }
3217
3218
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<11) // April 2009
3219 {
3220 3 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3221 3 }
3222
3223
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<12) // December 2009
3224 {
3225 3 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3226 3 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3227 3 }
3228
3229 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3230
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 13)
3231 {
3232 3 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3233 3 }
3234
3235 // Not entirely sure this is the best place for this...
3236 //2.50.2 bitmap offset fix
3237 99 memset(extra_rules, 0, EXTRARULES_SIZE);
3238
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3239 {
3240 30 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3241 30 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3242 30 }
3243 //required because quest templates also used this bit, although
3244 //it never did anything, before. -Z
3245
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 74 times.
99 if ( tempheader.zelda_version == 0x250 )
3246 {
3247
5/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 35 times.
74 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3248 {
3249 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3250 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3251 39 }
3252 74 }
3253
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if ( tempheader.zelda_version == 0x254 )
3254 {
3255 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3256 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3257 }
3258
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
99 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3259 {
3260 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3261 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3262 }
3263 //optimise fast drawing for older versions.
3264
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3265 {
3266 77 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3267 77 }
3268 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3269 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3270 //older quests can set the rule by hand. We need a new qst.dat again.
3271
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3272 {
3273 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3274 }
3275
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3276 {
3277 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3278 }
3279
4/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 77 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3280 {
3281 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3282 }
3283
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3284 {
3285 77 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3286 77 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3287 77 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3288 77 }
3289
3290 //item scripts continue to run
3291
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3292 {
3293 77 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3294 77 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3295 77 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3296 77 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3297 77 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3298 77 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3299 77 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3300 77 }
3301
3302
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3303 {
3304 77 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3305 77 }
3306
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3307 {
3308 77 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3309 77 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3310 77 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3311 77 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3312 77 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3313 77 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3314 77 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3315 77 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3316
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 1 times.
77 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3317 {
3318 1 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3319 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3320 //Now they **do**, unless you disable that behaviour.
3321 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3322 //now enable the disable L/R item swap on load.
3323 1 }
3324
3325 77 }
3326
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3327 {
3328 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3329 77 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3330 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3331 //animations ending earlier than they should.
3332 77 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3333 //Enemies would ignore solidity on the top half of combos
3334 77 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3335 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3336 77 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3337 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3338 77 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3339 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3340 77 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3341 77 }
3342
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x255 )
3343 {
3344 77 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3345 77 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3346 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3347 77 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3348 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3349 77 }
3350
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3351 {
3352 77 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3353 77 }
3354
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3355 {
3356 77 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3357 77 }
3358
3359
3360
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3361 {
3362 77 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3363 77 }
3364
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3365 {
3366 77 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3367 77 }
3368
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3369 {
3370 77 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3371 77 }
3372
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3373 {
3374 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3375
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3376 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3377 77 }
3378
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3379 {
3380 77 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3381 77 }
3382
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3383 {
3384 77 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3385 77 }
3386
3387
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( tempheader.zelda_version < 0x254 )
3388 {
3389 77 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3390 77 }
3391 //Sideview spikes in 2.50.0
3392
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3393 {
3394 25 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3395 25 }
3396 //more 2.50 fixes -Z
3397
6/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 23 times.
99 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3398 {
3399 54 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3400 54 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3401 54 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3402 54 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3403 54 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3404
3405 54 }
3406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3407 {
3408 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3409 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3410 }
3411
3412
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version < 0x193)
3413 {
3414 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3415 }
3416
3417
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(tempheader.zelda_version < 0x255)
3418 {
3419 77 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3420 77 }
3421
3422
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3423 {
3424 3 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3425 3 }
3426
3427
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3428 {
3429 77 set_bit(quest_rules,qr_OLD_F6,1);
3430 77 }
3431
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3432 {
3433 77 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3434 77 }
3435
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3436 {
3437 77 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3438 77 }
3439
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3440 {
3441 77 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3442 77 }
3443 //}
3444
3445
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 1)
3446 {
3447 //Enemies->Secret only affects flag 16-31
3448 77 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3449 77 }
3450
3451
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 2)
3452 {
3453 //Old CSet2 Handling
3454 77 set_bit(quest_rules,qr_OLDCS2,1);
3455 77 }
3456
3457
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 3)
3458 {
3459 //Hardcoded Shadow/Spawn/Death anim frames
3460 77 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3461 77 }
3462
3463
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 4)
3464 {
3465 //Hardcoded Shadow/Spawn/Death anim frames
3466 77 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3467 77 }
3468
3469
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 74 times.
99 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3470 {
3471 //Hardcoded Shadow/Spawn/Death anim frames
3472 74 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3473 74 }
3474
3475
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 6)
3476 {
3477 //Step->Secret (Temp) only affects flag 16-31
3478 77 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3479 77 }
3480
3481
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 7)
3482 {
3483 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3484 77 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3485 77 }
3486
3487
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 8)
3488 {
3489 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3490 77 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3491 77 }
3492
3493
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 9)
3494 {
3495 //Hardcoded BS Patras
3496 77 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3497 //Hardcoded Patra Inner Eye offsets
3498 77 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3499 //Broken 'Big enemy' animation style
3500 77 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3501 //Broken Attribute 31/32
3502 77 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3503 77 }
3504
3505
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 10)
3506 {
3507 //Shared candle use limits
3508 77 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3509 77 }
3510
3511
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 11)
3512 {
3513 //No cross-screen return points
3514 77 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3515 77 }
3516
3517
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 12)
3518 {
3519 //Old fire trail duration
3520 77 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3521 //Old Intro String in Ganon Room Behavior
3522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3523 77 else set_bit(quest_rules,qr_GANONINTRO,1);
3524 77 }
3525
3526
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
99 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3527 {
3528 //ANone doesn't reset to originaltile
3529 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3530 }
3531
3532
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 14)
3533 {
3534 //Old Bridge Combo Behavior
3535 77 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3536 77 }
3537
3538
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 15)
3539 {
3540 //Broken Z3 Animation
3541 77 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3542 77 }
3543
3544
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 16)
3545 {
3546 //Old Enemy Tile Behavior with Animation (None) Enemies
3547 77 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3548 77 }
3549
3550
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 17)
3551 {
3552 //Old Quake/DrawYOffset behavior
3553 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3554 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3555 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3556 77 }
3557
3558
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 18)
3559 {
3560 //Broken DrawScreen Derivative Functions
3561 77 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3562 //Scrolling Cancels Charge
3563 77 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3564 77 }
3565
3566
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 19)
3567 {
3568 //Broken Enemy Item Carrying with Large Enemies
3569 77 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3570 77 }
3571
3572
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 20)
3573 {
3574 77 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3575 77 }
3576
3577
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 21)
3578 {
3579 77 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3580 77 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3581 77 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3582 77 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3583 77 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3584 77 }
3585
3586
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 22)
3587 {
3588 77 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3589 77 }
3590
3591
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 23)
3592 {
3593 77 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3594 77 }
3595
3596
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 24)
3597 {
3598 77 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3599 77 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3600 77 }
3601
3602
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 25)
3603 {
3604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3605 77 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3606 77 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3607 77 }
3608
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 26)
3609 {
3610 77 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3611 77 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3612 77 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3613 77 }
3614
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3615 {
3616
2/2
✓ Branch 0 taken 23177 times.
✓ Branch 1 taken 77 times.
23254 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3617 23177 set_bit(quest_rules,q,0);
3618
2/2
✓ Branch 0 taken 8624 times.
✓ Branch 1 taken 77 times.
8701 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3619 8624 set_bit(quest_rules,q,0);
3620 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3621 77 }
3622
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 28)
3623 {
3624 79 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3625 79 }
3626
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 29)
3627 {
3628 79 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3629 79 }
3630
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 30)
3631 {
3632 79 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3633 79 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3634 79 }
3635
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 31)
3636 {
3637 79 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3638 79 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3639 79 }
3640
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 32)
3641 {
3642 79 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3643 79 }
3644
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(compatrule_version < 33)
3645 {
3646 79 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3647 79 }
3648
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(compatrule_version < 34)
3649 {
3650 86 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3651 86 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3652 86 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3653 86 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3654 86 }
3655
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 35)
3656 {
3657 // Leaving this commented for now, might need to enable later -Em
3658 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3659 88 }
3660
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 88 times.
99 if(compatrule_version < 36)
3661 {
3662 88 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3663 88 }
3664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(compatrule_version < 37)
3665 {
3666 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3667 99 }
3668
3669 //always set
3670 99 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3671
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
3673 {
3674 99 memcpy(Header, &tempheader, sizeof(tempheader));
3675 99 }
3676 99 return 0;
3677 99 }
3678
3679 816980 void init_msgstr(MsgStr *str)
3680 {
3681 816980 str->s = "";
3682 816980 str->s.shrink_to_fit();
3683 816980 str->nextstring=0;
3684 816980 str->tile=0;
3685 816980 str->cset=0;
3686 816980 str->trans=false;
3687 816980 str->font=font_zfont;
3688 816980 str->y=32;
3689 816980 str->sfx=18;
3690 816980 str->listpos=0;
3691 816980 str->x=24;
3692 816980 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3693 816980 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3694 816980 str->hspace=0;
3695 816980 str->vspace=0;
3696 816980 str->stringflags=0;
3697 816980 str->margins[up] = 8;
3698 816980 str->margins[down] = 0;
3699 816980 str->margins[left] = 8;
3700 816980 str->margins[right] = 0;
3701 816980 str->portrait_tile = 0;
3702 816980 str->portrait_cset = 0;
3703 816980 str->portrait_x = 0;
3704 816980 str->portrait_y = 0;
3705 816980 str->portrait_tw = 1;
3706 816980 str->portrait_th = 1;
3707 816980 str->shadow_type = 0;
3708 816980 str->shadow_color = 0;
3709 816980 str->drawlayer = 6;
3710 816980 }
3711
3712 99 void init_msgstrings(int32_t start, int32_t end)
3713 {
3714
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(end <= start || end-start > msg_strings_size)
3715 return;
3716
3717
2/2
✓ Branch 0 taken 811008 times.
✓ Branch 1 taken 99 times.
811107 for(int32_t i=start; i<end; i++)
3718 {
3719 811008 init_msgstr(&MsgStrings[i]);
3720 811008 MsgStrings[i].listpos=i;
3721 811008 }
3722
3723
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(start==0)
3724 {
3725 99 MsgStrings[0].s = "(None)";
3726 99 MsgStrings[0].listpos = 0;
3727 99 }
3728 99 }
3729
3730 99 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3731 {
3732 99 MsgStr tempMsgString;
3733
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstr(&tempMsgString);
3734
3735 99 word temp_msg_count=0;
3736 word temp_expansion[16];
3737 99 memset(temp_expansion, 0, 16*sizeof(word));
3738 99 char buf[8193] = {0};
3739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
3740 {
3741 byte tempbyte;
3742 int32_t strings_to_read=0;
3743 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3744 if((Header->zelda_version < 0x192)||
3745 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3746 {
3747 strings_to_read=128;
3748 temp_msg_count=Header->old_str_count;
3749
3750 // Some sort of string count corruption seems to be common in old quests
3751 if(temp_msg_count>128)
3752 {
3753 temp_msg_count=128;
3754 }
3755 }
3756 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3757 {
3758 strings_to_read=255;
3759 temp_msg_count=Header->old_str_count;
3760 }
3761 else
3762 {
3763 if(!p_igetw(&temp_msg_count,f,true))
3764 {
3765 return qe_invalid;
3766 }
3767
3768 strings_to_read=temp_msg_count;
3769
3770 if(temp_msg_count >= msg_strings_size)
3771 {
3772 Z_message("Reallocating string buffer...\n");
3773
3774 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3775 // return qe_nomem;
3776
3777 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3778 delete[] MsgStrings;
3779 MsgStrings = new MsgStr[MAXMSGS];
3780 msg_strings_size = MAXMSGS;
3781 for(auto q = 0; q < msg_strings_size; ++q)
3782 {
3783 MsgStrings[q].clear();
3784 }
3785 }
3786 }
3787
3788 //reset the message strings
3789 if(keepdata)
3790 {
3791 init_msgstrings(0,msg_strings_size);
3792 }
3793
3794 for(int32_t x=0; x<strings_to_read; x++)
3795 {
3796 init_msgstr(&tempMsgString);
3797
3798 if(!pfread(buf,73,f,true))
3799 {
3800 return qe_invalid;
3801 }
3802
3803 buf[74] = '\0';
3804 tempMsgString.s = buf;
3805
3806 if(!p_getc(&tempbyte,f,true))
3807 {
3808 return qe_invalid;
3809 }
3810
3811 if((Header->zelda_version < 0x192)||
3812 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3813 {
3814 tempMsgString.nextstring=tempbyte?x+1:0;
3815
3816 if(!p_getc(&tempbyte,f,true))
3817 {
3818 return qe_invalid;
3819 }
3820
3821 if(!p_getc(&tempbyte,f,true))
3822 {
3823 return qe_invalid;
3824 }
3825 }
3826 else
3827 {
3828 if(!p_igetw(&tempMsgString.nextstring,f,true))
3829 {
3830 return qe_invalid;
3831 }
3832
3833 if(!pfread(temp_expansion,32,f,true))
3834 {
3835 return qe_invalid;
3836 }
3837 }
3838
3839 if(keepdata==true)
3840 {
3841 MsgStrings[x] = tempMsgString;
3842 }
3843 }
3844 }
3845 else
3846 {
3847 int32_t dummy_int;
3848 word s_version;
3849 word s_cversion;
3850
3851 //section version info
3852
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
3853 {
3854 return qe_invalid;
3855 }
3856
3857 99 FFCore.quest_format[vStrings] = s_version;
3858
3859
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
3860 {
3861 return qe_invalid;
3862 }
3863
3864 //al_trace("Strings version %d\n", s_version);
3865 //section size
3866
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy_int,f,true))
3867 {
3868 return qe_invalid;
3869 }
3870
3871 //finally... section data
3872
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_msg_count,f,true))
3873 {
3874 return qe_invalid;
3875 }
3876
3877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(temp_msg_count >= msg_strings_size)
3878 {
3879 Z_message("Reallocating string buffer...\n");
3880
3881 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3882 // return qe_nomem;
3883 delete[] MsgStrings;
3884 MsgStrings = new MsgStr[MAXMSGS];
3885 msg_strings_size = MAXMSGS;
3886 for(auto q = 0; q < msg_strings_size; ++q)
3887 {
3888 MsgStrings[q].clear();
3889 }
3890 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3891 }
3892
3893 //reset the message strings
3894
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata)
3895 {
3896
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 7)
3897
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3898
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 init_msgstrings(0,msg_strings_size);
3899 99 }
3900
3901 99 int32_t string_length=(s_version<2)?73:145;
3902
3903
2/2
✓ Branch 0 taken 5873 times.
✓ Branch 1 taken 99 times.
5972 for(int32_t i=0; i<temp_msg_count; i++)
3904 {
3905
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 init_msgstr(&tempMsgString);
3906
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 5013 times.
5873 if(s_version > 8)
3907 {
3908
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&string_length,f,true))
3909 {
3910 return qe_invalid;
3911 }
3912 860 }
3913
2/2
✓ Branch 0 taken 5735 times.
✓ Branch 1 taken 138 times.
5873 if (string_length > 0)
3914 {
3915
2/4
✓ Branch 0 taken 5735 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5735 times.
✗ Branch 3 not taken.
5735 if (!pfread(buf, string_length, f, true))
3916 {
3917 return qe_invalid;
3918 }
3919 5735 }
3920 else
3921 {
3922 138 buf[0] = 0;
3923 }
3924
3925
2/4
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5873 times.
✗ Branch 3 not taken.
5873 if(!p_igetw(&tempMsgString.nextstring,f,true))
3926 {
3927 return qe_invalid;
3928 }
3929
3930
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 5357 times.
5873 if(s_version<2)
3931 {
3932 516 buf[72] = '\0';
3933
1/2
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
516 tempMsgString.s = buf;
3934 516 }
3935 else
3936 {
3937 // June 2008: A bug corrupted the last 4 chars of a string.
3938 // Discard these.
3939
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version<3)
3940 {
3941 for(int32_t j=140; j<144; j++)
3942 {
3943 buf[j] = '\0';
3944 }
3945 }
3946
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(string_length > 8192) string_length = 8192;
3947 5357 buf[string_length]='\0'; //Force-terminate
3948
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 tempMsgString.s = buf;
3949
3950
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if ( s_version >= 6 )
3951 {
3952
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.tile,f,true))
3953 {
3954 return qe_invalid;
3955 }
3956 860 }
3957 else
3958 {
3959
2/4
✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4497 times.
✗ Branch 3 not taken.
4497 if(!p_igetw(&tempMsgString.tile,f,true))
3960 {
3961 return qe_invalid;
3962 }
3963 }
3964
3965
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.cset,f,true))
3966 {
3967 return qe_invalid;
3968 }
3969
3970 byte dummy_char;
3971
3972
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3973 {
3974 return qe_invalid;
3975 }
3976
3977 5357 tempMsgString.trans=dummy_char!=0;
3978
3979
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.font,f,true))
3980 {
3981 return qe_invalid;
3982 }
3983
3984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5357 times.
5357 if(s_version < 5)
3985 {
3986 if(!p_getc(&tempMsgString.y,f,true))
3987 {
3988 return qe_invalid;
3989 }
3990 }
3991 else
3992 {
3993
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.x,f,true))
3994 {
3995 return qe_invalid;
3996 }
3997
3998
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.y,f,true))
3999 {
4000 return qe_invalid;
4001 }
4002
4003
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.w,f,true))
4004 {
4005 return qe_invalid;
4006 }
4007
4008
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.h,f,true))
4009 {
4010 return qe_invalid;
4011 }
4012
4013
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.hspace,f,true))
4014 {
4015 return qe_invalid;
4016 }
4017
4018
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.vspace,f,true))
4019 {
4020 return qe_invalid;
4021 }
4022
4023
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.stringflags,f,true))
4024 {
4025 return qe_invalid;
4026 }
4027 }
4028
4029
2/2
✓ Branch 0 taken 4497 times.
✓ Branch 1 taken 860 times.
5357 if(s_version >= 7)
4030 {
4031
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 3440 times.
4300 for(int32_t q = 0; q < 4; ++q)
4032 {
4033
2/4
✓ Branch 0 taken 3440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3440 times.
✗ Branch 3 not taken.
3440 if(!p_getc(&tempMsgString.margins[q],f,true))
4034 {
4035 return qe_invalid;
4036 }
4037 3440 }
4038
4039
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4040 {
4041 return qe_invalid;
4042 }
4043
4044
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4045 {
4046 return qe_invalid;
4047 }
4048
4049
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_x,f,true))
4050 {
4051 return qe_invalid;
4052 }
4053
4054
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_y,f,true))
4055 {
4056 return qe_invalid;
4057 }
4058
4059
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4060 {
4061 return qe_invalid;
4062 }
4063
4064
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.portrait_th,f,true))
4065 {
4066 return qe_invalid;
4067 }
4068 860 }
4069
4070
2/2
✓ Branch 0 taken 860 times.
✓ Branch 1 taken 4497 times.
5357 if(s_version >= 8)
4071 {
4072
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_type,f,true))
4073 {
4074 return qe_invalid;
4075 }
4076
4077
2/4
✓ Branch 0 taken 860 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 860 times.
✗ Branch 3 not taken.
860 if(!p_getc(&tempMsgString.shadow_color,f,true))
4078 {
4079 return qe_invalid;
4080 }
4081 860 }
4082
4083
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 4614 times.
5357 if(s_version >= 10)
4084 {
4085
2/4
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
743 if(!p_getc(&tempMsgString.drawlayer,f,true))
4086 {
4087 return qe_invalid;
4088 }
4089 743 }
4090
4091
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_getc(&tempMsgString.sfx,f,true))
4092 {
4093 return qe_invalid;
4094 }
4095
4096
1/2
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
5357 if(s_version>3)
4097 {
4098
2/4
✓ Branch 0 taken 5357 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5357 times.
✗ Branch 3 not taken.
5357 if(!p_igetw(&tempMsgString.listpos,f,true))
4099 {
4100 return qe_invalid;
4101 }
4102 5357 }
4103 }
4104
4105
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 if(keepdata==true)
4106 {
4107
1/2
✓ Branch 0 taken 5873 times.
✗ Branch 1 not taken.
5873 MsgStrings[i].copyAll(tempMsgString);
4108 5873 }
4109 5873 }
4110 }
4111
4112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4113 {
4114 99 msg_count=temp_msg_count;
4115 99 }
4116
4117 99 return 0;
4118 99 }
4119
4120 99 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4121 {
4122
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
4123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4124 {
4125 return 0;
4126 }
4127
4128 99 word temp_door_combo_set_count=0;
4129 DoorComboSet tempDoorComboSet;
4130 word dummy_word;
4131 int32_t dummy_long;
4132 byte padding;
4133 99 int32_t s_version = 0;
4134
4135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4136 {
4137
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4138 {
4139 25344 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4140 25344 }
4141 99 }
4142
4143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
4144 {
4145 //section version info
4146
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4147 {
4148 return qe_invalid;
4149 }
4150
4151 99 FFCore.quest_format[vDoors] = s_version;
4152
4153 //al_trace("Door combo sets version %d\n", dummy_word);
4154
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy_word,f,true))
4155 {
4156 return qe_invalid;
4157 }
4158
4159 //section size
4160
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy_long,f,true))
4161 {
4162 return qe_invalid;
4163 }
4164 99 }
4165
4166 //finally... section data
4167
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_door_combo_set_count,f,true))
4168 {
4169 return qe_invalid;
4170 }
4171
4172
2/2
✓ Branch 0 taken 727 times.
✓ Branch 1 taken 99 times.
826 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4173 {
4174 727 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4175
4176 //name
4177
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4178 {
4179 return qe_invalid;
4180 }
4181
4182
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4183 {
4184 if(!p_getc(&padding,f,true))
4185 {
4186 return qe_invalid;
4187 }
4188 }
4189
4190 //up door
4191
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4192 {
4193
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4194 {
4195
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4196 {
4197 return qe_invalid;
4198 }
4199 26172 }
4200 6543 }
4201
4202
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4203 {
4204
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4205 {
4206
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4207 {
4208 return qe_invalid;
4209 }
4210 26172 }
4211 6543 }
4212
4213 //down door
4214
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4215 {
4216
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4217 {
4218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26172 times.
26172 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4219 {
4220 return qe_invalid;
4221 }
4222 26172 }
4223 6543 }
4224
4225
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4226 {
4227
2/2
✓ Branch 0 taken 26172 times.
✓ Branch 1 taken 6543 times.
32715 for(int32_t k=0; k<4; k++)
4228 {
4229
1/2
✓ Branch 0 taken 26172 times.
✗ Branch 1 not taken.
26172 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4230 {
4231 return qe_invalid;
4232 }
4233 26172 }
4234 6543 }
4235
4236 //left door
4237
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4238 {
4239
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4240 {
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39258 times.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4242 {
4243 return qe_invalid;
4244 }
4245 39258 }
4246 6543 }
4247
4248
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4249 {
4250
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4251 {
4252
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4253 {
4254 return qe_invalid;
4255 }
4256 39258 }
4257 6543 }
4258
4259 //right door
4260
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4261 {
4262
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4263 {
4264
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4265 {
4266 return qe_invalid;
4267 }
4268 39258 }
4269 6543 }
4270
4271
2/2
✓ Branch 0 taken 6543 times.
✓ Branch 1 taken 727 times.
7270 for(int32_t j=0; j<9; j++)
4272 {
4273
2/2
✓ Branch 0 taken 39258 times.
✓ Branch 1 taken 6543 times.
45801 for(int32_t k=0; k<6; k++)
4274 {
4275
1/2
✓ Branch 0 taken 39258 times.
✗ Branch 1 not taken.
39258 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4276 {
4277 return qe_invalid;
4278 }
4279 39258 }
4280 6543 }
4281
4282 //up bomb rubble
4283
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4284 {
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4286 {
4287 return qe_invalid;
4288 }
4289 1454 }
4290
4291
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4292 {
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4294 {
4295 return qe_invalid;
4296 }
4297 1454 }
4298
4299 //down bomb rubble
4300
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4301 {
4302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4303 {
4304 return qe_invalid;
4305 }
4306 1454 }
4307
4308
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4309 {
4310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4311 {
4312 return qe_invalid;
4313 }
4314 1454 }
4315
4316 //left bomb rubble
4317
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4320 {
4321 return qe_invalid;
4322 }
4323 2181 }
4324
4325
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4326 {
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4328 {
4329 return qe_invalid;
4330 }
4331 2181 }
4332
4333
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4334 {
4335 if(!p_getc(&padding,f,true))
4336 {
4337 return qe_invalid;
4338 }
4339
4340 }
4341
4342 //right bomb rubble
4343
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4344 {
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4346 {
4347 return qe_invalid;
4348 }
4349 2181 }
4350
4351
2/2
✓ Branch 0 taken 2181 times.
✓ Branch 1 taken 727 times.
2908 for(int32_t j=0; j<3; j++)
4352 {
4353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2181 times.
2181 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4354 {
4355 return qe_invalid;
4356 }
4357 2181 }
4358
4359
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4360 {
4361 if(!p_getc(&padding,f,true))
4362 {
4363 return qe_invalid;
4364 }
4365 }
4366
4367 //walkthrough stuff
4368
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4369 {
4370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4371 {
4372 return qe_invalid;
4373 }
4374 2908 }
4375
4376
2/2
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 727 times.
3635 for(int32_t j=0; j<4; j++)
4377 {
4378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2908 times.
2908 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4379 {
4380 return qe_invalid;
4381 }
4382 2908 }
4383
4384 //flags
4385
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 727 times.
2181 for(int32_t j=0; j<2; j++)
4386 {
4387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4388 {
4389 return qe_invalid;
4390 }
4391 1454 }
4392
4393
1/2
✓ Branch 0 taken 727 times.
✗ Branch 1 not taken.
727 if(Header->zelda_version < 0x193)
4394 {
4395 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4396 {
4397 return qe_invalid;
4398 }
4399 }
4400
4401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 727 times.
727 if(keepdata==true)
4402 {
4403 727 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4404 727 }
4405 727 }
4406
4407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4408 {
4409 99 door_combo_set_count=temp_door_combo_set_count;
4410 99 }
4411
4412 99 return 0;
4413 99 }
4414
4415 int32_t count_dmaps()
4416 {
4417 int32_t i=MAXDMAPS-1;
4418 bool found=false;
4419
4420 while(i>=0 && !found)
4421 {
4422 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4423 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4424 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4425 found=true;
4426
4427 for(int32_t j=0; j<8; j++)
4428 {
4429 if(DMaps[i].grid[j]!=0)
4430
4431 found=true;
4432 }
4433
4434 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4435 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4436 found=true;
4437
4438 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4439 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4440 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4441 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4442 found=true;
4443
4444 if(!found)
4445 {
4446 i--;
4447 }
4448 }
4449
4450 return i+1;
4451 }
4452
4453
4454 int32_t count_shops(miscQdata *Misc)
4455 {
4456 int32_t i=255,j;
4457 bool found=false;
4458
4459 while(i>=0 && !found)
4460 {
4461 j=2;
4462
4463 while(j>=0 && !found)
4464 {
4465 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4466 {
4467 found=true;
4468 }
4469 else
4470 {
4471 j--;
4472 }
4473 }
4474
4475 if(Misc->shop[i].name[0]!=0)
4476 {
4477 found=true;
4478 }
4479
4480 if(!found)
4481 {
4482 i--;
4483 }
4484 }
4485
4486 return i+1;
4487 }
4488
4489 int32_t count_infos(miscQdata *Misc)
4490 {
4491 int32_t i=255,j;
4492 bool found=false;
4493
4494 while(i>=0 && !found)
4495 {
4496 j=2;
4497
4498 while(j>=0 && !found)
4499 {
4500 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4501 {
4502 found=true;
4503 }
4504 else
4505 {
4506 j--;
4507 }
4508 }
4509
4510 if(Misc->info[i].name[0]!=0)
4511 {
4512 found=true;
4513 }
4514
4515 if(!found)
4516 {
4517 i--;
4518 }
4519 }
4520
4521 return i+1;
4522 }
4523
4524 int32_t count_warprings(miscQdata *Misc)
4525 {
4526 int32_t i=15,j;
4527 bool found=false;
4528
4529 while(i>=0 && !found)
4530 {
4531 j=7;
4532
4533 while(j>=0 && !found)
4534 {
4535 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4536 {
4537 found=true;
4538 }
4539 else
4540 {
4541 j--;
4542 }
4543 }
4544
4545 if(!found)
4546 {
4547 i--;
4548 }
4549 }
4550
4551 return i+1;
4552 }
4553
4554 int32_t count_palcycles(miscQdata *Misc)
4555 {
4556 int32_t i=255,j;
4557 bool found=false;
4558
4559 while(i>=0 && !found)
4560 {
4561 j=2;
4562
4563 while(j>=0 && !found)
4564 {
4565 if(Misc->cycles[i][j].count!=0)
4566 {
4567 found=true;
4568 }
4569 else
4570 {
4571 j--;
4572 }
4573 }
4574
4575 if(!found)
4576 {
4577 i--;
4578 }
4579 }
4580
4581 return i+1;
4582 }
4583
4584 158267 void clear_screen(mapscr *temp_scr)
4585 {
4586 158267 temp_scr->zero_memory();
4587 158267 }
4588
4589 99 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4590 {
4591 99 word dmapstoread=0;
4592 dmap tempDMap;
4593
4594 int32_t dummy;
4595 99 word s_version=0, s_cversion=0;
4596 byte padding;
4597
4598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
4599 {
4600
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<max_dmaps; i++)
4601 {
4602 50688 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4603 50688 sprintf(DMaps[start_dmap+i].title," ");
4604 50688 sprintf(DMaps[start_dmap+i].intro," ");
4605 50688 DMaps[start_dmap+i].type |= dmCAVE;
4606 50688 }
4607 99 }
4608
4609
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!Header || Header->zelda_version > 0x192)
4610 {
4611 //section version info
4612
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
4613 {
4614 return qe_invalid;
4615 }
4616
4617 99 FFCore.quest_format[vDMaps] = s_version;
4618
4619 //al_trace("DMaps version %d\n", s_version);
4620
4621
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
4622 {
4623 return qe_invalid;
4624 }
4625
4626 //section size
4627
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
4628 {
4629 return qe_invalid;
4630 }
4631
4632 //finally... section data
4633
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dmapstoread,f,true))
4634 {
4635 return qe_invalid;
4636 }
4637 99 }
4638 else
4639 {
4640 if((Header->zelda_version < 0x192)||
4641 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4642 {
4643 dmapstoread=32;
4644 }
4645 else if(s_version <= 4)
4646 {
4647 dmapstoread=OLDMAXDMAPS;
4648 }
4649 else
4650 {
4651 dmapstoread=MAXDMAPS;
4652 }
4653 }
4654
4655
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, max_dmaps);
4656
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4657
4658
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4659 {
4660 49920 memset(&tempDMap,0,sizeof(dmap));
4661 49920 sprintf(tempDMap.title," ");
4662 49920 sprintf(tempDMap.intro," ");
4663
4664
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.map,f,keepdata))
4665 {
4666 return qe_invalid;
4667 }
4668
4669
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version <= 4)
4670 {
4671 byte tempbyte;
4672
4673
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,keepdata))
4674 {
4675 return qe_invalid;
4676 }
4677
4678 768 tempDMap.level=(word)tempbyte;
4679 768 }
4680 else
4681 {
4682
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.level,f,keepdata))
4683 {
4684 return qe_invalid;
4685 }
4686 }
4687
4688
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.xoff,f,keepdata))
4689 {
4690 return qe_invalid;
4691 }
4692
4693
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.compass,f,keepdata))
4694 {
4695 return qe_invalid;
4696 }
4697
4698
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version > 8) // February 2009
4699 {
4700
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&tempDMap.color,f,true))
4701 {
4702 return qe_invalid;
4703 }
4704 49152 }
4705 else
4706 {
4707 byte tempbyte;
4708
4709
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,true))
4710 {
4711 return qe_invalid;
4712 }
4713
4714 768 tempDMap.color = (word)tempbyte;
4715 }
4716
4717
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.midi,f,keepdata))
4718 {
4719 return qe_invalid;
4720 }
4721
4722
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.cont,f,keepdata))
4723 {
4724 return qe_invalid;
4725 }
4726
4727
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.type,f,keepdata))
4728 {
4729 return qe_invalid;
4730 }
4731
4732
3/4
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 49551 times.
✓ Branch 2 taken 369 times.
✗ Branch 3 not taken.
50289 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4733
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4734 369 tempDMap.xoff = 0;
4735
4736
2/2
✓ Branch 0 taken 399360 times.
✓ Branch 1 taken 49920 times.
449280 for(int32_t j=0; j<8; j++)
4737 {
4738
1/2
✓ Branch 0 taken 399360 times.
✗ Branch 1 not taken.
399360 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4739 {
4740 return qe_invalid;
4741 }
4742 399360 }
4743
4744
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4745 {
4746 if(tempDMap.level>0&&tempDMap.level<10)
4747 {
4748 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4749 }
4750
4751 if(i==0 && Header->zelda_version <= 0x190)
4752 {
4753 tempDMap.cont-=tempDMap.xoff;
4754 tempDMap.compass-=tempDMap.xoff;
4755 }
4756
4757 //forgotten -DD
4758 if(tempDMap.level==0)
4759 {
4760 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4761 }
4762 }
4763 else
4764 {
4765
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4766 {
4767 return qe_invalid;
4768 }
4769
4770
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4771 {
4772 return qe_invalid;
4773 }
4774
4775
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4776 {
4777 return qe_invalid;
4778 }
4779
4780
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 49920 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4781 {
4782 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4783 if(keepdata==true)
4784 {
4785 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4786 }
4787
4788 continue;
4789 }
4790
4791
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4792 {
4793 if(!p_getc(&padding,f,keepdata))
4794 {
4795 return qe_invalid;
4796 }
4797 }
4798
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4799 {
4800
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4801 {
4802 return qe_invalid;
4803 }
4804 11264 }
4805 else
4806 {
4807
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4808 {
4809 return qe_invalid;
4810 }
4811 }
4812
4813
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4814 {
4815 return qe_invalid;
4816 }
4817
4818
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4819 {
4820 if(!p_getc(&padding,f,keepdata))
4821 {
4822 return qe_invalid;
4823 }
4824 }
4825
4826
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4827 {
4828
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4829 {
4830 return qe_invalid;
4831 }
4832 11264 }
4833 else
4834 {
4835
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4836 {
4837 return qe_invalid;
4838 }
4839 }
4840
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4841 {
4842 return qe_invalid;
4843 }
4844
4845
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4846 {
4847 if(!p_getc(&padding,f,keepdata))
4848 {
4849 return qe_invalid;
4850 }
4851 }
4852
4853
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4854 {
4855
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4856 {
4857 return qe_invalid;
4858 }
4859 11264 }
4860 else
4861 {
4862
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4863 {
4864 return qe_invalid;
4865 }
4866 }
4867
4868
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4869 {
4870 return qe_invalid;
4871 }
4872
4873
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(Header && (Header->zelda_version < 0x193))
4874 {
4875
4876 if(!p_getc(&padding,f,keepdata))
4877 {
4878 return qe_invalid;
4879 }
4880 }
4881
4882
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version >= 11 )
4883 {
4884
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4885 {
4886 return qe_invalid;
4887 }
4888 11264 }
4889 else
4890 {
4891
1/2
✓ Branch 0 taken 38656 times.
✗ Branch 1 not taken.
38656 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4892 {
4893 return qe_invalid;
4894 }
4895 }
4896
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4897 {
4898 return qe_invalid;
4899 }
4900
4901
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4902 {
4903 return qe_invalid;
4904 }
4905 }
4906
4907
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>1)
4908 {
4909
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4910 {
4911 return qe_invalid;
4912 }
4913
4914
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4915 {
4916 return qe_invalid;
4917 }
4918
4919
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4920 {
4921 return qe_invalid;
4922 }
4923 49152 }
4924
4925
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 49152 times.
49920 if(s_version>2)
4926 {
4927 byte di[32];
4928
4929
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(&di, 32, f, true)) return qe_invalid;
4930
4931
2/2
✓ Branch 0 taken 12582912 times.
✓ Branch 1 taken 49152 times.
12632064 for(int32_t j=0; j<MAXITEMS; j++)
4932 {
4933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12582912 times.
12582912 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4934 12582912 else tempDMap.disableditems[j]=0;
4935 12582912 }
4936 49152 }
4937
4938
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version >= 6)
4939 {
4940
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&tempDMap.flags,f,keepdata))
4941 {
4942 return qe_invalid;
4943 }
4944 49152 }
4945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
768 else if(s_version>3)
4946 {
4947 char temp;
4948
4949 if(!p_getc(&temp,f,keepdata))
4950 {
4951 return qe_invalid;
4952 }
4953
4954 tempDMap.flags = temp;
4955 }
4956
3/8
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 573 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
768 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4957 {
4958 573 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4959 573 }
4960 else
4961 195 tempDMap.flags=0;
4962
4963
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<7)
4964 {
4965
3/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 573 times.
✗ Branch 3 not taken.
768 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4966 573 tempDMap.flags|= dmfVIEWMAP;
4967 768 }
4968
4969
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 768 times.
49920 if(s_version<8)
4970 {
4971
4/4
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 531 times.
768 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4972 {
4973 531 tempDMap.type &= ~dmDNGN;
4974 531 tempDMap.type |= dmCAVE;
4975 531 }
4976
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 105 times.
237 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4977 {
4978 105 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4979 105 }
4980 768 }
4981
4982
3/8
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49920 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 49920 times.
✗ Branch 7 not taken.
49920 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4983 49920 && (Header->zelda_version < 0x193))
4984 {
4985 if(!p_getc(&padding,f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989 }
4990
4991
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 10)
4992 {
4993
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempDMap.sideview,f,keepdata))
4994 {
4995 return qe_invalid;
4996 }
4997 11264 }
4998
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version < 10) tempDMap.sideview = 0;
4999
5000 //Dmap Scripts
5001
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 12)
5002 {
5003
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.script,f,keepdata))
5004 {
5005 return qe_invalid;
5006 }
5007
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
5008 {
5009
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5010 {
5011 return qe_invalid;
5012 }
5013 90112 }
5014 11264 }
5015
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 12 )
5016 {
5017 38656 tempDMap.script = 0;
5018
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
5019 {
5020 309248 tempDMap.initD[q] = 0;
5021 309248 }
5022 38656 }
5023
5024
2/2
✓ Branch 0 taken 38656 times.
✓ Branch 1 taken 11264 times.
49920 if(s_version >= 13)
5025 {
5026
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
5027 {
5028
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
5029 {
5030
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5031 {
5032 return qe_invalid;
5033 }
5034 5857280 }
5035 90112 }
5036 11264 }
5037
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if ( s_version < 13 )
5038 {
5039 38656 tempDMap.script = 0;
5040
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for ( int32_t q = 0; q < 8; q++ )
5041 {
5042
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for ( int32_t w = 0; w < 65; w++ )
5043 20101120 tempDMap.initD_label[q][w] = 0;
5044 309248 }
5045 38656 }
5046
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 14)
5047 {
5048
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5049 {
5050 return qe_invalid;
5051 }
5052
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5053 {
5054 return qe_invalid;
5055 }
5056
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5057 {
5058
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5059 {
5060 return qe_invalid;
5061 }
5062 90112 }
5063
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5064 {
5065
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5066 {
5067
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5068 {
5069 return qe_invalid;
5070 }
5071 5857280 }
5072 90112 }
5073 11264 }
5074 else
5075 {
5076 38656 tempDMap.active_sub_script = 0;
5077 38656 tempDMap.passive_sub_script = 0;
5078
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5079 {
5080 309248 tempDMap.sub_initD[q] = 0;
5081
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5082 20101120 tempDMap.sub_initD_label[q][w] = 0;
5083 309248 }
5084 }
5085
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 15)
5086 {
5087
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5088 {
5089 return qe_invalid;
5090 }
5091
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; ++q )
5092 {
5093
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5094 {
5095 return qe_invalid;
5096 }
5097 90112 }
5098
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for(int32_t q = 0; q < 8; ++q)
5099 {
5100
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; ++w )
5101 {
5102
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5103 {
5104 return qe_invalid;
5105 }
5106 5857280 }
5107 90112 }
5108 11264 }
5109 else
5110 {
5111 38656 tempDMap.onmap_script = 0;
5112
2/2
✓ Branch 0 taken 309248 times.
✓ Branch 1 taken 38656 times.
347904 for(int32_t q = 0; q < 8; ++q)
5113 {
5114 309248 tempDMap.onmap_initD[q] = 0;
5115
2/2
✓ Branch 0 taken 20101120 times.
✓ Branch 1 taken 309248 times.
20410368 for(int32_t w = 0; w < 65; ++w)
5116 {
5117 20101120 tempDMap.onmap_initD_label[q][w] = 0;
5118 20101120 }
5119 309248 }
5120 }
5121
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 38656 times.
49920 if(s_version >= 16)
5122 {
5123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11264 times.
11264 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5124 {
5125 return qe_invalid;
5126 }
5127 11264 }
5128 else
5129 {
5130 38656 tempDMap.mirrorDMap = -1;
5131 }
5132
5133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
5134 {
5135 49920 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5136 49920 }
5137 49920 }
5138
5139 99 return 0;
5140 99 }
5141
5142 96 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5143 {
5144 //these are here to bypass compiler warnings about unused arguments
5145 96 Header=Header;
5146
5147 miscQdata temp_misc;
5148 96 word s_version=0, s_cversion=0;
5149 96 int32_t tempsize=0;
5150 word dummyw;
5151
5152 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5153
5154 //section version info
5155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5156 {
5157 return qe_invalid;
5158 }
5159
5160 96 FFCore.quest_format[vColours] = s_version;
5161
5162 96 al_trace("Misc Colours section version: %d\n", s_version);
5163
5164 //al_trace("Misc. colors version %d\n", s_version);
5165
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5166 {
5167 return qe_invalid;
5168 }
5169
5170
5171 //section size
5172
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5173 {
5174 return qe_invalid;
5175 }
5176
5177 //finally... section data
5178 96 readsize=0;
5179
5180
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.text,f,true))
5181 {
5182 return qe_invalid;
5183 }
5184
5185
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.caption,f,true))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5196 {
5197 return qe_invalid;
5198 }
5199
5200
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5201 {
5202 return qe_invalid;
5203 }
5204
5205
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5206 {
5207 return qe_invalid;
5208 }
5209
5210
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5211 {
5212 return qe_invalid;
5213 }
5214
5215
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5216 {
5217 return qe_invalid;
5218 }
5219
5220
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5221 {
5222 return qe_invalid;
5223 }
5224
5225
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5226 {
5227 return qe_invalid;
5228 }
5229
5230
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5231 {
5232 return qe_invalid;
5233 }
5234
5235
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5236 {
5237 return qe_invalid;
5238 }
5239
5240
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5241 {
5242 return qe_invalid;
5243 }
5244
5245
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5246 {
5247 return qe_invalid;
5248 }
5249
5250
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5251 {
5252 return qe_invalid;
5253 }
5254
5255
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5266 {
5267 return qe_invalid;
5268 }
5269
5270
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5271 {
5272 return qe_invalid;
5273 }
5274
5275
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5276 {
5277 return qe_invalid;
5278 }
5279
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version < 4)
5280 {
5281
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5282 return qe_invalid;
5283 74 temp_misc.colors.triforce_tile = dummyw;
5284
5285
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5286 return qe_invalid;
5287 74 temp_misc.colors.triframe_tile = dummyw;
5288
5289
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5290 return qe_invalid;
5291 74 temp_misc.colors.overworld_map_tile = dummyw;
5292
5293
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5294 return qe_invalid;
5295 74 temp_misc.colors.dungeon_map_tile = dummyw;
5296
5297
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5298 return qe_invalid;
5299 74 temp_misc.colors.blueframe_tile = dummyw;
5300
5301
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5302 return qe_invalid;
5303 74 temp_misc.colors.HCpieces_tile = dummyw;
5304 74 }
5305
5306
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5307 {
5308 return qe_invalid;
5309 }
5310
5311
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5312 {
5313 return qe_invalid;
5314 }
5315
5316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 2)
5317 {
5318 temp_misc.colors.msgtext = 0x01;
5319 }
5320 else
5321 {
5322
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5323 {
5324 return qe_invalid;
5325 }
5326 }
5327
5328
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if ( s_version >= 3 ) //expanded tile pages to 825
5329 {
5330
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5346 {
5347 return qe_invalid;
5348 }
5349
5350
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5351 {
5352 return qe_invalid;
5353 }
5354
5355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5356 {
5357 return qe_invalid;
5358 }
5359 22 }
5360
5361
5362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5363 {
5364 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5365 96 }
5366
5367 96 return 0;
5368 96 }
5369
5370 96 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5371 {
5372 miscQdata temp_misc;
5373 96 word s_version=0, s_cversion=0;
5374 byte icons;
5375 96 int32_t tempsize=0;
5376
5377 96 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5378
5379 //section version info
5380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
5381 {
5382 return qe_invalid;
5383 }
5384
5385 96 FFCore.quest_format[vIcons] = s_version;
5386
5387 //al_trace("Game icons version %d\n", s_version);
5388
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
5389 {
5390 return qe_invalid;
5391 }
5392
5393
5394 //section size
5395
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&tempsize,f,true))
5396 {
5397 return qe_invalid;
5398 }
5399
5400 //finally... section data
5401 96 readsize=0;
5402
5403 96 icons=4;
5404
5405
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 10 )
5406 {
5407
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<icons; i++)
5408 {
5409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&temp_misc.icons[i],f,true))
5410 {
5411 return qe_invalid;
5412 }
5413 88 }
5414 22 }
5415 else
5416 {
5417
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<icons; i++)
5418 {
5419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(!p_igetw(&temp_misc.icons[i],f,true))
5420 {
5421 return qe_invalid;
5422 }
5423 296 }
5424 }
5425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata==true)
5426 {
5427 96 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5428 96 }
5429
5430 96 return 0;
5431 96 }
5432
5433 99 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5434 {
5435 99 word maxinfos=256;
5436 99 word maxshops=256;
5437 99 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5438 99 word ponds=16, pondsize=72, expansionsize=98*2;
5439 byte tempbyte, padding;
5440 miscQdata temp_misc;
5441 99 word s_version=0, s_cversion=0;
5442 word swaptmp;
5443 99 int32_t tempsize=0;
5444
5445 99 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5446
5447
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5448 {
5449 25344 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5450 25344 }
5451
5452
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5453 {
5454 25344 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5455 25344 }
5456
5457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5458 {
5459 //section version info
5460
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
5461 {
5462 return qe_invalid;
5463 }
5464
5465 99 FFCore.quest_format[vMisc] = s_version;
5466
5467 //al_trace("Misc. data version %d\n", s_version);
5468
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
5469 {
5470 return qe_invalid;
5471 }
5472
5473
5474 //section size
5475
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempsize,f,true))
5476 {
5477 return qe_invalid;
5478 }
5479 99 }
5480
5481 //finally... section data
5482 99 readsize=0;
5483
5484 //shops
5485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5486 {
5487
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&shops,f,true))
5488 {
5489 return qe_invalid;
5490 }
5491 99 }
5492
5493
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 99 times.
1101 for(int32_t i=0; i<shops; i++)
5494 {
5495
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 6)
5496 {
5497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978 times.
978 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5498 {
5499 return qe_invalid;
5500 }
5501 978 }
5502
5503
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5504 {
5505
1/2
✓ Branch 0 taken 3006 times.
✗ Branch 1 not taken.
3006 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5506 {
5507 return qe_invalid;
5508 }
5509
5510
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 72 times.
3006 if(s_version < 4)
5511 {
5512 72 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5513 72 }
5514 3006 }
5515
5516
1/2
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
1002 if(Header->zelda_version < 0x193)
5517 {
5518 if(!p_getc(&tempbyte,f,true))
5519 {
5520 return qe_invalid;
5521 }
5522 }
5523
5524
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 1002 times.
4008 for(int32_t j=0; j<3; j++)
5525 {
5526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3006 times.
3006 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5527 {
5528 return qe_invalid;
5529 }
5530 3006 }
5531
5532
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 978 times.
1002 if(s_version > 3)
5533 {
5534
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 978 times.
3912 for(int32_t j=0; j<3; j++)
5535 {
5536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2934 times.
2934 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5537 return qe_invalid;
5538 2934 }
5539 978 }
5540
5541 /*
5542 if(s_version < 8)
5543 {
5544 for(int32_t j=0; j<3; j++)
5545 {
5546 (&temp_misc.shop[i].str[j])=0; //initialise.
5547 }
5548 }
5549 */
5550 1002 }
5551
5552 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5553
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxshops; ++i)
5554 {
5555
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5556 {
5557
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5558 {
5559
2/2
✓ Branch 0 taken 2146 times.
✓ Branch 1 taken 73886 times.
76032 if(temp_misc.shop[i].hasitem[k]==0)
5560 {
5561 73886 swaptmp = temp_misc.shop[i].item[k];
5562 73886 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5563 73886 temp_misc.shop[i].item[k+1] = swaptmp;
5564 73886 swaptmp = temp_misc.shop[i].price[k];
5565 73886 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5566 73886 temp_misc.shop[i].price[k+1] = swaptmp;
5567 73886 swaptmp = temp_misc.shop[i].hasitem[k];
5568 73886 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5569 73886 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5570 73886 }
5571 76032 }
5572 50688 }
5573 25344 }
5574
5575 //infos
5576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5577 {
5578
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&infos,f,true))
5579 {
5580 return qe_invalid;
5581 }
5582 99 }
5583
5584
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 99 times.
1532 for(int32_t i=0; i<infos; i++)
5585 {
5586
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1424 times.
1433 if(s_version > 6)
5587 {
5588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1424 times.
1424 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5589 {
5590 return qe_invalid;
5591 }
5592 1424 }
5593
5594
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5595 {
5596
1/4
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4299 if((Header->zelda_version < 0x192)||
5597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5598 {
5599 if(!p_getc(&tempbyte,f,true))
5600 {
5601 return qe_invalid;
5602 }
5603
5604 temp_misc.info[i].str[j]=tempbyte;
5605 }
5606 else
5607 {
5608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4299 times.
4299 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5609 {
5610 return qe_invalid;
5611 }
5612 }
5613 4299 }
5614
5615
1/2
✓ Branch 0 taken 1433 times.
✗ Branch 1 not taken.
1433 if(Header->zelda_version < 0x193)
5616 {
5617 if(!p_getc(&tempbyte,f,true))
5618 {
5619 return qe_invalid;
5620 }
5621 }
5622
5623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1433 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1433 if((Header->zelda_version == 0x192)&&(Header->build>145))
5624 {
5625 if(!p_getc(&padding,f,true))
5626 {
5627 return qe_invalid;
5628 }
5629 }
5630
5631
2/2
✓ Branch 0 taken 4299 times.
✓ Branch 1 taken 1433 times.
5732 for(int32_t j=0; j<3; j++)
5632 {
5633
1/2
✓ Branch 0 taken 4299 times.
✗ Branch 1 not taken.
4299 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5634 {
5635 return qe_invalid;
5636 }
5637 4299 }
5638 1433 }
5639
5640 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5641
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<maxinfos; ++i)
5642 {
5643
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 25344 times.
76032 for(int32_t j=0; j<3-1; j++)
5644 {
5645
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 50688 times.
126720 for(int32_t k=0; k<2-j; k++)
5646 {
5647
2/2
✓ Branch 0 taken 1728 times.
✓ Branch 1 taken 74304 times.
76032 if(temp_misc.info[i].str[k]==0)
5648 {
5649 74304 swaptmp = temp_misc.info[i].str[k];
5650 74304 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5651 74304 temp_misc.info[i].str[k+1] = swaptmp;
5652 74304 swaptmp = temp_misc.info[i].price[k];
5653 74304 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5654 74304 temp_misc.info[i].price[k+1] = swaptmp;
5655 74304 }
5656 76032 }
5657 50688 }
5658 25344 }
5659
5660
5661 //warp rings
5662
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version > 5)
5663 96 warprings++;
5664
5665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
5666 {
5667
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&warprings,f,true))
5668 {
5669 return qe_invalid;
5670 }
5671 99 }
5672
5673
2/2
✓ Branch 0 taken 958 times.
✓ Branch 1 taken 99 times.
1057 for(int32_t i=0; i<warprings; i++)
5674 {
5675
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5676 {
5677
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 8190 times.
8574 if(s_version <= 3)
5678 {
5679
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f,true))
5680 {
5681 return qe_invalid;
5682 }
5683
5684 384 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5685 384 }
5686 else
5687 {
5688
1/2
✓ Branch 0 taken 8190 times.
✗ Branch 1 not taken.
8190 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5689 {
5690 return qe_invalid;
5691 }
5692 }
5693 8574 }
5694
5695
2/2
✓ Branch 0 taken 8574 times.
✓ Branch 1 taken 958 times.
9532 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5696 {
5697
1/2
✓ Branch 0 taken 8574 times.
✗ Branch 1 not taken.
8574 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5698 {
5699 return qe_invalid;
5700 }
5701 8574 }
5702
5703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 958 times.
958 if(!p_getc(&temp_misc.warp[i].size,f,true))
5704 {
5705 return qe_invalid;
5706 }
5707
5708
1/2
✓ Branch 0 taken 958 times.
✗ Branch 1 not taken.
958 if(Header->zelda_version < 0x193)
5709 {
5710 if(!p_getc(&tempbyte,f,true))
5711 {
5712 return qe_invalid;
5713 }
5714 }
5715 958 }
5716
5717 //palette cycles
5718
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5719 {
5720 for(int32_t i=0; i<256; i++)
5721 {
5722 for(int32_t j=0; j<3; j++)
5723 {
5724 temp_misc.cycles[i][j].first=0;
5725 temp_misc.cycles[i][j].count=0;
5726 temp_misc.cycles[i][j].speed=0;
5727 }
5728 }
5729
5730 if((Header->zelda_version < 0x192)||
5731 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5732 {
5733 palcycles=16;
5734 }
5735
5736 for(int32_t i=0; i<palcycles; i++)
5737 {
5738 for(int32_t j=0; j<3; j++)
5739 {
5740 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5741 {
5742 return qe_invalid;
5743 }
5744
5745 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5746 {
5747 return qe_invalid;
5748 }
5749
5750 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5751 {
5752 return qe_invalid;
5753 }
5754 }
5755 }
5756 }
5757
5758 //Wind warps are now just another warp ring.
5759
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version <= 5)
5760 {
5761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(Header->zelda_version > 0x192)
5762 {
5763
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&windwarps,f,true))
5764 {
5765 return qe_invalid;
5766 }
5767 3 }
5768
5769
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 3 times.
30 for(int32_t i=0; i<windwarps; i++)
5770 {
5771
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version <= 3)
5772 {
5773
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(!p_getc(&tempbyte,f,true))
5774 {
5775 return qe_invalid;
5776 }
5777
5778 27 temp_misc.warp[8].dmap[i]=tempbyte;
5779 27 }
5780 else
5781 {
5782 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5783 {
5784 return qe_invalid;
5785 }
5786 }
5787
5788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5789 {
5790 return qe_invalid;
5791 }
5792
5793 27 temp_misc.warp[8].size = 9;
5794
5795
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(s_version == 5)
5796 {
5797 if(!p_getc(&tempbyte,f,true))
5798 {
5799 return qe_invalid;
5800 }
5801 }
5802 27 }
5803 3 }
5804
5805
5806 //triforce pieces
5807
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<triforces; i++)
5808 {
5809
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 if(!p_getc(&temp_misc.triforce[i],f,true))
5810 {
5811 return qe_invalid;
5812 }
5813 792 }
5814
5815 //misc color data
5816
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<3)
5817 {
5818
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.text,f,true))
5819 {
5820 return qe_invalid;
5821 }
5822
5823
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.caption,f,true))
5824 {
5825 return qe_invalid;
5826 }
5827
5828
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5829 {
5830 return qe_invalid;
5831 }
5832
5833
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5834 {
5835 return qe_invalid;
5836 }
5837
5838
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5839 {
5840 return qe_invalid;
5841 }
5842
5843
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5844 {
5845 return qe_invalid;
5846 }
5847
5848
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5849 {
5850 return qe_invalid;
5851 }
5852
5853
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5854 {
5855 return qe_invalid;
5856 }
5857
5858
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5859 {
5860 return qe_invalid;
5861 }
5862
5863
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5864 {
5865 return qe_invalid;
5866 }
5867
5868
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5869 {
5870 return qe_invalid;
5871 }
5872
5873
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5874 {
5875 return qe_invalid;
5876 }
5877
5878
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5879 {
5880 return qe_invalid;
5881 }
5882
5883
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5884 {
5885 return qe_invalid;
5886 }
5887
5888
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5889 {
5890 return qe_invalid;
5891 }
5892
5893
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5894 {
5895 return qe_invalid;
5896 }
5897
5898
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5899 {
5900 return qe_invalid;
5901 }
5902
5903
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5904 {
5905 return qe_invalid;
5906 }
5907
5908
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5909 {
5910 return qe_invalid;
5911 }
5912
5913
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5914 {
5915 return qe_invalid;
5916 }
5917
5918
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5919 {
5920 return qe_invalid;
5921 }
5922
5923
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5924 {
5925 return qe_invalid;
5926 }
5927
5928
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5929 {
5930 return qe_invalid;
5931 }
5932
5933
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5934 {
5935 return qe_invalid;
5936 }
5937
5938
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5939 {
5940 return qe_invalid;
5941 }
5942
5943
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5944 {
5945 return qe_invalid;
5946 }
5947
5948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5949 {
5950 return qe_invalid;
5951 }
5952
5953 3 temp_misc.colors.msgtext = 0x01;
5954
5955
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version < 0x193)
5956 {
5957 for(int32_t i=0; i<7; i++)
5958 {
5959 if(!p_getc(&tempbyte,f,true))
5960 {
5961 return qe_invalid;
5962 }
5963 }
5964 }
5965
5966
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>145))
5967 {
5968 for(int32_t i=0; i<256; i++)
5969 {
5970 if(!p_getc(&tempbyte,f,true))
5971 {
5972 return qe_invalid;
5973 }
5974 }
5975 }
5976
5977
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(s_version>1)
5978 {
5979 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5980 {
5981 return qe_invalid;
5982 }
5983 }
5984
5985 //save game icons
5986
1/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version < 0x192)||
5987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5988 {
5989 icons=3;
5990 }
5991
5992
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 for(int32_t i=0; i<icons; i++)
5993 {
5994
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_misc.icons[i],f,true))
5995 {
5996 return qe_invalid;
5997 }
5998 12 }
5999 3 }
6000
6001
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
6002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6003 {
6004 if(keepdata==true)
6005 {
6006 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6007 }
6008
6009 return 0;
6010 }
6011
6012 //pond information
6013
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
6014 {
6015 if((Header->zelda_version == 0x192)&&(Header->build<146))
6016 {
6017 pondsize=25;
6018 }
6019
6020 for(int32_t i=0; i<ponds; i++)
6021 {
6022 for(int32_t j=0; j<pondsize; j++)
6023 {
6024 if(!p_getc(&tempbyte,f,true))
6025 {
6026 return qe_invalid;
6027
6028 }
6029 }
6030 }
6031 }
6032
6033 //end string
6034
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
6035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6036 {
6037 if(!p_getc(&tempbyte,f,true))
6038 {
6039 return qe_invalid;
6040 }
6041
6042 temp_misc.endstring=tempbyte;
6043
6044 if(!p_getc(&tempbyte,f,true))
6045 {
6046 return qe_invalid;
6047 }
6048 }
6049 else
6050 {
6051
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&temp_misc.endstring,f,true))
6052 {
6053 return qe_invalid;
6054 }
6055 }
6056
6057 //expansion
6058
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
6059 {
6060 if((Header->zelda_version == 0x192)&&(Header->build<73))
6061 {
6062 expansionsize=99*2;
6063 }
6064
6065 for(int32_t i=0; i<expansionsize; i++)
6066 {
6067 if(!p_getc(&tempbyte,f,true))
6068 {
6069 return qe_invalid;
6070 }
6071 }
6072 }
6073 //shops v8
6074
6075
6076
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 8)
6077 {
6078
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 22 times.
342 for(int32_t i=0; i<shops; i++)
6079 {
6080
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 320 times.
1280 for(int32_t j=0; j<3; j++)
6081 {
6082
1/2
✓ Branch 0 taken 960 times.
✗ Branch 1 not taken.
960 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6083 return qe_invalid;
6084 960 }
6085 320 }
6086 22 }
6087
6088 99 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6089 99 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6090 99 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6091
6092 //v9 includes quest misc[32]
6093
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version >= 9)
6094 {
6095
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6096 {
6097
1/2
✓ Branch 0 taken 704 times.
✗ Branch 1 not taken.
704 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6098 return qe_invalid;
6099 704 }
6100
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 22 times.
726 for ( int32_t q = 0; q < 32; q++ )
6101 {
6102
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 704 times.
90816 for ( int32_t j = 0; j < 128; j++ )
6103
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6104 return qe_invalid;
6105 704 }
6106 22 }
6107
6108
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 11 )
6109 {
6110
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6111 return qe_invalid;
6112 22 }
6113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version < 11 )
6114 {
6115 77 temp_misc.zscript_last_compiled_version = -1;
6116 77 }
6117
6118 99 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6119
6120
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 12)
6121 {
6122 byte spr;
6123
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sprMAX; ++q)
6124 {
6125
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&spr,f,true))
6126 return qe_invalid;
6127 5632 temp_misc.sprites[q] = spr;
6128 5632 }
6129 22 }
6130 else
6131 {
6132 77 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6133 //temp_misc.sprites[sprFALL] = ;
6134 }
6135
6136
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 13)
6137 {
6138
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 22 times.
1430 for(size_t q = 0; q < 64; ++q)
6139 {
6140 1408 bottletype* bt = &(temp_misc.bottle_types[q]);
6141
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!pfread(bt->name, 32, f, true))
6142 return qe_invalid;
6143
2/2
✓ Branch 0 taken 4224 times.
✓ Branch 1 taken 1408 times.
5632 for(size_t j = 0; j < 3; ++j)
6144 {
6145
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_getc(&(bt->counter[j]), f, true))
6146 return qe_invalid;
6147
1/2
✓ Branch 0 taken 4224 times.
✗ Branch 1 not taken.
4224 if (!p_igetw(&(bt->amount[j]), f, true))
6148 return qe_invalid;
6149 4224 }
6150
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->flags), f, true))
6151 return qe_invalid;
6152
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if (!p_getc(&(bt->next_type), f, true))
6153 return qe_invalid;
6154 1408 }
6155
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(size_t q = 0; q < 256; ++q)
6156 {
6157 5632 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6158
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if (!pfread(bst->name, 32, f, true))
6159 return qe_invalid;
6160
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 5632 times.
22528 for(size_t j = 0; j < 3; ++j)
6161 {
6162
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->fill[j]), f, true))
6163 return qe_invalid;
6164
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->comb[j]), f, true))
6165 return qe_invalid;
6166
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_getc(&(bst->cset[j]), f, true))
6167 return qe_invalid;
6168
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->price[j]), f, true))
6169 return qe_invalid;
6170
1/2
✓ Branch 0 taken 16896 times.
✗ Branch 1 not taken.
16896 if (!p_igetw(&(bst->str[j]), f, true))
6171 return qe_invalid;
6172 16896 }
6173 5632 }
6174 22 }
6175 else
6176 {
6177
2/2
✓ Branch 0 taken 4928 times.
✓ Branch 1 taken 77 times.
5005 for(size_t q = 0; q < 64; ++q)
6178 4928 temp_misc.bottle_types[q].clear();
6179
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 77 times.
19789 for(size_t q = 0; q < 256; ++q)
6180 19712 temp_misc.bottle_shop_types[q].clear();
6181 }
6182
6183
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version >= 14)
6184 {
6185 byte msfx;
6186
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t q = 0; q < sfxMAX; ++q)
6187 {
6188
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&msfx,f,true))
6189 return qe_invalid;
6190 5632 temp_misc.miscsfx[q] = msfx;
6191 5632 }
6192 22 }
6193 else
6194 {
6195 77 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6196 77 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6197 77 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6198 }
6199
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version < 15)
6200 {
6201 77 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6202 77 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6203 77 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6204 77 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6205 77 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6206 77 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6207 77 }
6208
6209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
6210 {
6211 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6212 99 }
6213
6214 99 return 0;
6215 99 }
6216
6217 extern char *item_string[ITEMCNT];
6218 extern const char *old_item_string[iLast];
6219 extern char *weapon_string[WPNCNT];
6220 extern const char *old_weapon_string[wLast];
6221
6222 99 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6223 {
6224 byte padding;
6225 int32_t dummy;
6226 99 word items_to_read=MAXITEMS;
6227 itemdata tempitem;
6228 99 word s_version=0, s_cversion=0;
6229 word dummy_word;
6230
6231
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(version < 0x186)
6232 {
6233 items_to_read=64;
6234 }
6235
6236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
6237 {
6238 99 items_to_read=0;
6239
6240 //section version info
6241
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
6242 {
6243 return qe_invalid;
6244 }
6245
6246 99 FFCore.quest_format[vItems] = s_version;
6247
6248 //al_trace("Items version %d\n", s_version);
6249
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
6250 {
6251 return qe_invalid;
6252 }
6253
6254 //section size
6255
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
6256 {
6257 return qe_invalid;
6258 }
6259
6260 //finally... section data
6261
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&items_to_read,f,true))
6262 {
6263 return qe_invalid;
6264 }
6265 99 }
6266
6267
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>1)
6268 {
6269
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<items_to_read; i++)
6270 {
6271 char tempname[64];
6272
6273
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
6274 {
6275 return qe_invalid;
6276 }
6277
6278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
6279 {
6280 24576 strcpy(item_string[i], tempname);
6281 24576 }
6282 24576 }
6283 96 }
6284 else
6285 {
6286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
6287 {
6288
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<ITEMCNT; i++)
6289 {
6290 768 reset_itemname(i);
6291 768 }
6292 3 }
6293 }
6294
6295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
6296 {
6297
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
6298 {
6299 25344 itemdata& id = itemsbuf[i];
6300 25344 memset(&id, 0, sizeof(itemdata));
6301 25344 id.count=-1;
6302 25344 id.playsound=WAV_SCALE;
6303 25344 reset_itembuf(&id,i);
6304 25344 }
6305 99 }
6306
6307
2/2
✓ Branch 0 taken 24786 times.
✓ Branch 1 taken 99 times.
24885 for(int32_t i=0; i<items_to_read; i++)
6308 {
6309 24786 memset(&tempitem, 0, sizeof(itemdata));
6310 24786 reset_itembuf(&tempitem,i);
6311
6312
6313
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19154 times.
24786 if ( s_version > 35 ) //expanded tiles
6314 {
6315
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tile,f,true))
6316 {
6317 return qe_invalid;
6318 }
6319 5632 }
6320 else
6321 {
6322
1/2
✓ Branch 0 taken 19154 times.
✗ Branch 1 not taken.
19154 if(!p_igetw(&tempitem.tile,f,true))
6323 {
6324 return qe_invalid;
6325 }
6326 }
6327
6328
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.misc_flags,f,true))
6329 {
6330 return qe_invalid;
6331 }
6332
6333
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.csets,f,true))
6334 {
6335 return qe_invalid;
6336 }
6337
6338
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.frames,f,true))
6339 {
6340 return qe_invalid;
6341 }
6342
6343
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.speed,f,true))
6344 {
6345 return qe_invalid;
6346 }
6347
6348
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_getc(&tempitem.delay,f,true))
6349 {
6350 return qe_invalid;
6351 }
6352
6353
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6354 {
6355 if(!p_getc(&padding,f,true))
6356 {
6357 return qe_invalid;
6358 }
6359
6360 if((version < 0x192)||((version == 0x192)&&(build<186)))
6361 {
6362 switch(i)
6363 {
6364 case iShield:
6365 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6366 break;
6367
6368 case iMShield:
6369 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6370 break;
6371
6372 default:
6373 tempitem.ltm=0;
6374 break;
6375 }
6376
6377 tempitem.count=-1;
6378 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6379 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6380 tempitem.family=0xFF;
6381 tempitem.playsound=WAV_SCALE;
6382 reset_itembuf(&tempitem,i);
6383
6384 if(keepdata==true)
6385 {
6386 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6387 }
6388
6389 continue;
6390 }
6391 }
6392
6393
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(!p_igetl(&tempitem.ltm,f,true))
6394 {
6395 return qe_invalid;
6396 }
6397
6398
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(version < 0x193)
6399 {
6400 for(int32_t q=0; q<12; q++)
6401 {
6402 if(!p_getc(&padding,f,true))
6403 {
6404 return qe_invalid;
6405 }
6406 }
6407 }
6408
6409
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 210 times.
24786 if(s_version>1)
6410 {
6411
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if ( s_version >= 31 )
6412 {
6413
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.family,f,true))
6414 {
6415 return qe_invalid;
6416 }
6417 5632 }
6418 else
6419 {
6420
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.family,f,true))
6421 {
6422 return qe_invalid;
6423 }
6424 }
6425
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version < 16)
6426 if(tempitem.family == 0xFF)
6427 tempitem.family = itype_misc;
6428
6429
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.fam_type,f,true))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6435 {
6436
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version>=31)
6437 {
6438
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.power,f,true))
6439 {
6440 return qe_invalid;
6441 }
6442 5632 }
6443 else
6444 {
6445
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.power,f,true))
6446 {
6447 return qe_invalid;
6448 }
6449 }
6450
6451 //converted flags from 16b to 32b -Z
6452
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version < 41 )
6453 {
6454
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempitem.flags,f,true))
6455 {
6456 return qe_invalid;
6457 }
6458 18944 }
6459 else
6460 {
6461
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.flags,f,true))
6462 {
6463 return qe_invalid;
6464 }
6465 }
6466 24576 }
6467 else
6468 {
6469 //tempitem.power = tempitem.fam_type;
6470 char tempchar;
6471
6472 if(!p_getc(&tempchar,f,true))
6473 {
6474 return qe_invalid;
6475 }
6476
6477 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6478 }
6479
6480
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.script,f,true))
6481 {
6482 return qe_invalid;
6483 }
6484
6485
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6486 {
6487 if(tempitem.script > NUMSCRIPTITEM)
6488 {
6489 tempitem.script = 0;
6490 }
6491 }
6492
6493
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.count,f,true))
6494 {
6495 return qe_invalid;
6496 }
6497
6498
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.amount,f,true))
6499 {
6500 return qe_invalid;
6501 }
6502
6503
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.collect_script,f,true))
6504 {
6505 return qe_invalid;
6506 }
6507
6508
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<=3)
6509 {
6510 if(tempitem.collect_script > NUMSCRIPTITEM)
6511 {
6512 tempitem.collect_script = 0;
6513 }
6514 }
6515
6516
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.setmax,f,true))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetw(&tempitem.max,f,true))
6522 {
6523 return qe_invalid;
6524 }
6525
6526
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.playsound,f,true))
6527 {
6528 return qe_invalid;
6529 }
6530
6531
2/2
✓ Branch 0 taken 196608 times.
✓ Branch 1 taken 24576 times.
221184 for(int32_t j=0; j<8; j++)
6532 {
6533
1/2
✓ Branch 0 taken 196608 times.
✗ Branch 1 not taken.
196608 if(!p_igetl(&tempitem.initiald[j],f,true))
6534 {
6535 return qe_invalid;
6536 }
6537 196608 }
6538
6539
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 24576 times.
73728 for(int32_t j=0; j<2; j++)
6540 {
6541
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&tempitem.initiala[j],f,true))
6542 {
6543 return qe_invalid;
6544 }
6545 49152 }
6546
6547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>4)
6548 {
6549
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version>5)
6550 {
6551
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn,f,true))
6552 {
6553 return qe_invalid;
6554 }
6555
6556
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn2,f,true))
6557 {
6558 return qe_invalid;
6559 }
6560
6561
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn3,f,true))
6562 {
6563 return qe_invalid;
6564 }
6565
6566
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn4,f,true))
6567 {
6568 return qe_invalid;
6569 }
6570
6571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=15)
6572 {
6573
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn5,f,true))
6574 {
6575 return qe_invalid;
6576 }
6577
6578
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn6,f,true))
6579 {
6580 return qe_invalid;
6581 }
6582
6583
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn7,f,true))
6584 {
6585 return qe_invalid;
6586 }
6587
6588
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn8,f,true))
6589 {
6590 return qe_invalid;
6591 }
6592
6593
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn9,f,true))
6594 {
6595 return qe_invalid;
6596 }
6597
6598
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.wpn10,f,true))
6599 {
6600 return qe_invalid;
6601 }
6602 24576 }
6603
6604
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.pickup_hearts,f,true))
6605 {
6606 return qe_invalid;
6607 }
6608
6609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6610 {
6611 if(!p_igetw(&dummy_word,f,true))
6612 {
6613 return qe_invalid;
6614 }
6615
6616 tempitem.misc1=dummy_word;
6617
6618 if(!p_igetw(&dummy_word,f,true))
6619 {
6620 return qe_invalid;
6621 }
6622
6623 tempitem.misc2=dummy_word;
6624 }
6625 else
6626 {
6627
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc1,f,true))
6628 {
6629 return qe_invalid;
6630 }
6631
6632
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc2,f,true))
6633 {
6634 return qe_invalid;
6635 }
6636
6637 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6638
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(s_version<24)
6639 {
6640 if(tempitem.family==itype_shield)
6641 {
6642 tempitem.misc1|=shSCRIPT;
6643 }
6644 }
6645 }
6646
6647
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if(s_version < 53)
6648 {
6649 byte tempbyte;
6650
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempbyte,f,true))
6651 {
6652 return qe_invalid;
6653 }
6654 18944 tempitem.cost_amount[0] = tempbyte;
6655 18944 }
6656 else
6657 {
6658
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6659 {
6660
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6661 {
6662 return qe_invalid;
6663 }
6664 11264 }
6665 }
6666 24576 }
6667 else
6668 {
6669 char tempchar;
6670
6671 if(!p_getc(&tempchar,f,true))
6672 {
6673 return qe_invalid;
6674 }
6675
6676 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6677 }
6678
6679 // June 2007: more misc. attributes
6680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version>=12)
6681 {
6682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(s_version<15)
6683 {
6684 if(!p_igetw(&dummy_word,f,true))
6685 {
6686 return qe_invalid;
6687 }
6688
6689 tempitem.misc3=dummy_word;
6690
6691 if(!p_igetw(&dummy_word,f,true))
6692 {
6693 return qe_invalid;
6694 }
6695
6696 tempitem.misc4=dummy_word;
6697 }
6698 else
6699 {
6700
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc3,f,true))
6701 {
6702 return qe_invalid;
6703 }
6704
6705
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc4,f,true))
6706 {
6707 return qe_invalid;
6708 }
6709
6710
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc5,f,true))
6711 {
6712 return qe_invalid;
6713 }
6714
6715
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc6,f,true))
6716 {
6717 return qe_invalid;
6718 }
6719
6720
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc7,f,true))
6721 {
6722 return qe_invalid;
6723 }
6724
6725
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc8,f,true))
6726 {
6727 return qe_invalid;
6728 }
6729
6730
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc9,f,true))
6731 {
6732 return qe_invalid;
6733 }
6734
6735
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_igetl(&tempitem.misc10,f,true))
6736 {
6737 return qe_invalid;
6738 }
6739 }
6740
6741
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!p_getc(&tempitem.usesound,f,true))
6742 {
6743 return qe_invalid;
6744 }
6745
6746
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 18944 times.
24576 if(s_version >= 49)
6747 {
6748
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usesound2,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752 5632 }
6753 18944 else tempitem.usesound2 = 0;
6754
6755
3/4
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
24576 if(s_version < 50 && tempitem.family == itype_mirror)
6756 {
6757 //Split continue/dmap warp effect/sfx, port for old
6758 tempitem.misc2 = tempitem.misc1;
6759 tempitem.usesound2 = tempitem.usesound;
6760 }
6761 24576 }
6762 24576 }
6763
6764
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6765 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6766
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.useweapon,f,true))
6767 {
6768 return qe_invalid;
6769 }
6770
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.usedefence,f,true))
6771 {
6772 return qe_invalid;
6773 }
6774
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weaprange,f,true))
6775 {
6776 return qe_invalid;
6777 }
6778
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapduration,f,true))
6779 {
6780 return qe_invalid;
6781 }
6782
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 5632 times.
61952 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6783 {
6784
1/2
✓ Branch 0 taken 56320 times.
✗ Branch 1 not taken.
56320 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6785 {
6786 return qe_invalid;
6787 }
6788 56320 }
6789 5632 }
6790
6791
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6792 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6793
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.duplicates,f,true))
6794 {
6795 return qe_invalid;
6796 }
6797
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < INITIAL_D; q++ )
6798 {
6799
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6800 {
6801 return qe_invalid;
6802 }
6803 45056 }
6804
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < INITIAL_A; q++ )
6805 {
6806
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6807 {
6808 return qe_invalid;
6809 }
6810 11264 }
6811
6812
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&tempitem.drawlayer,f,true))
6813 {
6814 return qe_invalid;
6815 }
6816
6817
6818
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxofs,f,true))
6819 {
6820 return qe_invalid;
6821 }
6822
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hyofs,f,true))
6823 {
6824 return qe_invalid;
6825 }
6826
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hxsz,f,true))
6827 {
6828 return qe_invalid;
6829 }
6830
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hysz,f,true))
6831 {
6832 return qe_invalid;
6833 }
6834
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.hzsz,f,true))
6835 {
6836 return qe_invalid;
6837 }
6838
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.xofs,f,true))
6839 {
6840 return qe_invalid;
6841 }
6842
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.yofs,f,true))
6843 {
6844 return qe_invalid;
6845 }
6846
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6847 {
6848 return qe_invalid;
6849 }
6850
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6851 {
6852 return qe_invalid;
6853 }
6854
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6855 {
6856 return qe_invalid;
6857 }
6858
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hysz,f,true))
6859 {
6860 return qe_invalid;
6861 }
6862
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6863 {
6864 return qe_invalid;
6865 }
6866
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_xofs,f,true))
6867 {
6868 return qe_invalid;
6869 }
6870
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_yofs,f,true))
6871 {
6872 return qe_invalid;
6873 }
6874
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.weaponscript,f,true))
6875 {
6876 return qe_invalid;
6877 }
6878
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.wpnsprite,f,true))
6879 {
6880 return qe_invalid;
6881 }
6882 5632 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6883
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < num_cost_tmr; ++q)
6884 {
6885
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6886 {
6887 return qe_invalid;
6888 }
6889 11264 }
6890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 for(auto q = num_cost_tmr; q < 2; ++q)
6891 tempitem.magiccosttimer[q] = 0;
6892 5632 }
6893
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6894 {
6895 //Item Size FLags, TileWidth, TileHeight
6896
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6897 {
6898 return qe_invalid;
6899 }
6900
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tilew,f,true))
6901 {
6902 return qe_invalid;
6903 }
6904
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.tileh,f,true))
6905 {
6906 return qe_invalid;
6907 }
6908 5632 }
6909
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 29 ) //! More new vars.
6910 {
6911 //Item Size FLags, TileWidth, TileHeight
6912
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6913 {
6914 return qe_invalid;
6915 }
6916
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tilew,f,true))
6917 {
6918 return qe_invalid;
6919 }
6920
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.weap_tileh,f,true))
6921 {
6922 return qe_invalid;
6923 }
6924 5632 }
6925
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 30 ) //! More new vars.
6926 {
6927 //Pickup Type
6928
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempitem.pickup,f,true))
6929 {
6930 return qe_invalid;
6931 }
6932 5632 }
6933
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 32 ) //! More new vars.
6934 {
6935 //Pickup Type
6936
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pstring,f,true))
6937 {
6938 return qe_invalid;
6939 }
6940 5632 }
6941
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 33 ) //! More new vars.
6942 {
6943 //Pickup Type
6944
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6945 {
6946 return qe_invalid;
6947 }
6948 5632 }
6949
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 34 ) //! cost counter
6950 {
6951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 if(s_version < 53)
6952 {
6953 if(!p_getc(&tempitem.cost_counter[0],f,true))
6954 {
6955 return qe_invalid;
6956 }
6957 }
6958 else
6959 {
6960
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for(auto q = 0; q < 2; ++q)
6961 {
6962
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&tempitem.cost_counter[q],f,true))
6963 {
6964 return qe_invalid;
6965 }
6966 11264 }
6967 }
6968 5632 }
6969
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 44 ) //! sprite scripts
6970 {
6971
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
6972 {
6973
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6974 {
6975
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6976 {
6977 return qe_invalid;
6978 }
6979 2928640 }
6980
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6981 {
6982
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6983 {
6984 return qe_invalid;
6985 }
6986 2928640 }
6987
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
6988 {
6989
1/2
✓ Branch 0 taken 2928640 times.
✗ Branch 1 not taken.
2928640 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6990 {
6991 return qe_invalid;
6992 }
6993 2928640 }
6994
1/2
✓ Branch 0 taken 45056 times.
✗ Branch 1 not taken.
45056 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6995 {
6996 return qe_invalid;
6997 }
6998
6999 45056 }
7000
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < 2; q++ )
7001 {
7002
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7003 {
7004 return qe_invalid;
7005 }
7006 11264 }
7007 //Pickup Type
7008
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempitem.sprite_script,f,true))
7009 {
7010 return qe_invalid;
7011 }
7012 5632 }
7013
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5632 times.
24576 if ( s_version >= 48 ) //! pickup flags
7014 {
7015
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7016 {
7017 return qe_invalid;
7018 }
7019 5632 }
7020 24576 }
7021 else
7022 {
7023 210 tempitem.count=-1;
7024 210 tempitem.family=itype_misc;
7025 210 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7026 210 tempitem.playsound=WAV_SCALE;
7027 210 reset_itembuf(&tempitem,i);
7028 }
7029
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19154 times.
24786 if(s_version < 53)
7030 {
7031
4/4
✓ Branch 0 taken 18756 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 77 times.
19154 switch(tempitem.family)
7032 {
7033 case itype_arrow:
7034 229 tempitem.cost_counter[1] = crARROWS;
7035 229 tempitem.cost_amount[1] = 1;
7036 229 break;
7037 case itype_bomb:
7038 92 tempitem.cost_counter[1] = crBOMBS;
7039 92 tempitem.cost_amount[1] = 1;
7040 92 break;
7041 case itype_sbomb:
7042 77 tempitem.cost_counter[1] = crSBOMBS;
7043 77 tempitem.cost_amount[1] = 1;
7044 77 break;
7045 default:
7046 18756 tempitem.cost_counter[1] = crNONE;
7047 18756 tempitem.cost_amount[1] = 0;
7048 18756 }
7049 19154 tempitem.magiccosttimer[1] = 0;
7050 19154 }
7051
7052
1/2
✓ Branch 0 taken 24786 times.
✗ Branch 1 not taken.
24786 if(keepdata==true)
7053 {
7054 24786 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7055 24786 }
7056 else if(zgpmode)
7057 {
7058 itemsbuf[i].tile=tempitem.tile;
7059 itemsbuf[i].misc_flags=tempitem.misc_flags;
7060 itemsbuf[i].csets=tempitem.csets;
7061 itemsbuf[i].frames=tempitem.frames;
7062 itemsbuf[i].speed=tempitem.speed;
7063 itemsbuf[i].delay=tempitem.delay;
7064 itemsbuf[i].ltm=tempitem.ltm;
7065 }
7066 24786 }
7067
7068 //////////////////////////////////////////////////////
7069 // Now do any updates because of new item additions
7070 // (These can't be done above because items_to_read
7071 // might be too low.)
7072 //////////////////////////////////////////////////////
7073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
7074 {
7075
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMS; i++)
7076 {
7077 25344 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7078
7079 //Account for older quests that didn't have an actual item for the used letter
7080
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 2 && i==iLetterUsed)
7081 {
7082 3 reset_itembuf(&tempitem, iLetterUsed);
7083 3 strcpy(item_string[i],old_item_string[i]);
7084 3 tempitem.tile = itemsbuf[iLetter].tile;
7085 3 tempitem.csets = itemsbuf[iLetter].csets;
7086 3 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7087 3 tempitem.frames = itemsbuf[iLetter].frames;
7088 3 tempitem.speed = itemsbuf[iLetter].speed;
7089 3 tempitem.ltm = itemsbuf[iLetter].ltm;
7090 3 }
7091
7092
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 3)
7093 {
7094
3/3
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 699 times.
✓ Branch 2 taken 3 times.
768 switch(i)
7095 {
7096 case iRocsFeather:
7097 case iHoverBoots:
7098 case iSpinScroll:
7099 case iL2SpinScroll:
7100 case iCrossScroll:
7101 case iQuakeScroll:
7102 case iL2QuakeScroll:
7103 case iWhispRing:
7104 case iL2WhispRing:
7105 case iChargeRing:
7106 case iL2ChargeRing:
7107 case iPerilScroll:
7108 case iWalletL3:
7109 case iQuiverL4:
7110 case iBombBagL4:
7111 case iBracelet:
7112 case iL2Bracelet:
7113 case iOldGlove:
7114 case iL2Ladder:
7115 case iWealthMedal:
7116 case iL2WealthMedal:
7117 case iL3WealthMedal:
7118 66 reset_itembuf(&tempitem, i);
7119 66 strcpy(item_string[i],old_item_string[i]);
7120 66 break;
7121
7122 case iSShield:
7123 3 reset_itembuf(&tempitem, i);
7124 3 strcpy(item_string[i],old_item_string[i]);
7125 3 strcpy(item_string[iShield],old_item_string[iShield]);
7126 3 strcpy(item_string[iMShield],old_item_string[iMShield]);
7127 3 break;
7128 }
7129 768 }
7130
7131
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 5)
7132 {
7133
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 747 times.
768 switch(i)
7134 {
7135 case iHeartRing:
7136 case iL2HeartRing:
7137 case iL3HeartRing:
7138 case iMagicRing:
7139 case iL2MagicRing:
7140 case iL3MagicRing:
7141 case iL4MagicRing:
7142 21 reset_itembuf(&tempitem, i);
7143 21 strcpy(item_string[i],old_item_string[i]);
7144 21 break;
7145 }
7146 768 }
7147
7148
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7149 {
7150
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(i!=iBPotion && i!=iRPotion)
7151 762 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7152
7153
43/43
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 3 times.
✓ Branch 18 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 20 taken 3 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 26 taken 3 times.
✓ Branch 27 taken 3 times.
✓ Branch 28 taken 3 times.
✓ Branch 29 taken 3 times.
✓ Branch 30 taken 3 times.
✓ Branch 31 taken 3 times.
✓ Branch 32 taken 3 times.
✓ Branch 33 taken 3 times.
✓ Branch 34 taken 3 times.
✓ Branch 35 taken 3 times.
✓ Branch 36 taken 3 times.
✓ Branch 37 taken 3 times.
✓ Branch 38 taken 3 times.
✓ Branch 39 taken 3 times.
✓ Branch 40 taken 3 times.
✓ Branch 41 taken 3 times.
✓ Branch 42 taken 3 times.
768 switch(i)
7154 {
7155 case iTriforce:
7156 3 tempitem.fam_type=1;
7157 3 break;
7158
7159 case iBigTri:
7160 3 tempitem.fam_type=0;
7161 3 break;
7162
7163 case iBombs:
7164 3 tempitem.fam_type=i_bomb;
7165 3 tempitem.power=4;
7166 3 tempitem.wpn=wBOMB;
7167 3 tempitem.wpn2=wBOOM;
7168 3 tempitem.misc1 = 50;
7169
7170
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7171
7172 3 break;
7173
7174 case iSBomb:
7175 3 tempitem.fam_type=i_sbomb;
7176 3 tempitem.power=16;
7177 3 tempitem.wpn=wSBOMB;
7178 3 tempitem.wpn2=wSBOOM;
7179 3 tempitem.misc1 = 50;
7180
7181
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7182
7183 3 break;
7184
7185 case iBook:
7186
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, 113))
7187 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7188
7189 3 break;
7190
7191 case iSArrow:
7192 3 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7193 3 tempitem.power=4;
7194 3 tempitem.flags|=ITEM_GAMEDATA;
7195 3 tempitem.wpn=wSARROW;
7196 3 break;
7197
7198 case iGArrow:
7199 3 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7200 3 tempitem.power=8;
7201 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7202 3 tempitem.wpn=wGARROW;
7203 3 break;
7204
7205 case iBrang:
7206 3 tempitem.power=0;
7207 3 tempitem.wpn=wBRANG;
7208 3 tempitem.misc1=36;
7209 3 break;
7210
7211 case iMBrang:
7212 3 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7213 3 tempitem.power=0;
7214 3 tempitem.wpn=wMBRANG;
7215 3 break;
7216
7217 case iFBrang:
7218 3 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7219 3 tempitem.power=2;
7220 3 tempitem.wpn=wFBRANG;
7221 3 break;
7222
7223 case iBoots:
7224 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7225 3 tempitem.power=7;
7226 3 break;
7227
7228 case iWand:
7229 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7230 3 tempitem.power=2;
7231 3 tempitem.wpn=wWAND;
7232 3 tempitem.wpn3=wMAGIC;
7233 3 break;
7234
7235 case iBCandle:
7236 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7237 3 tempitem.power=1;
7238 3 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7239 3 tempitem.wpn3=wFIRE;
7240 3 break;
7241
7242 case iRCandle:
7243 3 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7244 3 tempitem.power=1;
7245 3 tempitem.wpn3=wFIRE;
7246 3 break;
7247
7248 case iSword:
7249 3 tempitem.power=1;
7250 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7251 3 tempitem.wpn=tempitem.wpn3=wSWORD;
7252 3 tempitem.wpn2=wSWORDSLASH;
7253 3 break;
7254
7255 case iWSword:
7256 3 tempitem.power=2;
7257 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7258 3 tempitem.wpn=tempitem.wpn3=wWSWORD;
7259 3 tempitem.wpn2=wWSWORDSLASH;
7260 3 break;
7261
7262 case iMSword:
7263 3 tempitem.power=4;
7264 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7265 3 tempitem.wpn=tempitem.wpn3=wMSWORD;
7266 3 tempitem.wpn2=wMSWORDSLASH;
7267 3 break;
7268
7269 case iXSword:
7270 3 tempitem.power=8;
7271 3 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7272 3 tempitem.wpn=tempitem.wpn3=wXSWORD;
7273 3 tempitem.wpn2=wXSWORDSLASH;
7274 3 break;
7275
7276 case iNayrusLove:
7277 3 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7278 3 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7279 3 tempitem.wpn=wNAYRUSLOVE1A;
7280 3 tempitem.wpn2=wNAYRUSLOVE1B;
7281 3 tempitem.wpn3=wNAYRUSLOVES1A;
7282 3 tempitem.wpn4=wNAYRUSLOVES1B;
7283 3 tempitem.wpn6=wNAYRUSLOVE2A;
7284 3 tempitem.wpn7=wNAYRUSLOVE2B;
7285 3 tempitem.wpn8=wNAYRUSLOVES2A;
7286 3 tempitem.wpn9=wNAYRUSLOVES2B;
7287 3 tempitem.wpn5 = iwNayrusLoveShieldFront;
7288 3 tempitem.wpn10 = iwNayrusLoveShieldBack;
7289 3 tempitem.misc1=512;
7290 3 tempitem.cost_amount[0]=64;
7291 3 break;
7292
7293 case iLens:
7294 3 tempitem.misc1=60;
7295 3 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7296 3 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7297 3 break;
7298
7299 case iArrow:
7300 3 tempitem.power=2;
7301 3 tempitem.wpn=wARROW;
7302 3 break;
7303
7304 case iHoverBoots:
7305 3 tempitem.misc1=45;
7306 3 tempitem.wpn=iwHover;
7307 3 break;
7308
7309 case iDinsFire:
7310 3 tempitem.power=8;
7311 3 tempitem.wpn=wDINSFIRE1A;
7312 3 tempitem.wpn2=wDINSFIRE1B;
7313 3 tempitem.wpn3=wDINSFIRES1A;
7314 3 tempitem.wpn4=wDINSFIRES1B;
7315 3 tempitem.misc1 = 32;
7316 3 tempitem.misc2 = 200;
7317 3 tempitem.cost_amount[0]=32;
7318 3 break;
7319
7320 case iFaroresWind:
7321 3 tempitem.cost_amount[0]=32;
7322 3 break;
7323
7324 case iHookshot:
7325 3 tempitem.power=0;
7326 3 tempitem.flags&=~ITEM_FLAG1;
7327 3 tempitem.wpn=wHSHEAD;
7328 3 tempitem.wpn2=wHSCHAIN_H;
7329 3 tempitem.wpn4=wHSHANDLE;
7330 3 tempitem.wpn3=wHSCHAIN_V;
7331 3 tempitem.misc1=50;
7332 3 tempitem.misc2=100;
7333 3 break;
7334
7335 case iLongshot:
7336 3 tempitem.power=0;
7337 3 tempitem.flags&=~ITEM_FLAG1;
7338 3 tempitem.wpn=wLSHEAD;
7339 3 tempitem.wpn2=wLSCHAIN_H;
7340 3 tempitem.wpn4=wLSHANDLE;
7341 3 tempitem.wpn3=wLSCHAIN_V;
7342 3 tempitem.misc1=99;
7343 3 tempitem.misc2=100;
7344 3 break;
7345
7346 case iHammer:
7347 3 tempitem.power=4;
7348 3 tempitem.wpn=wHAMMER;
7349 3 tempitem.wpn2=iwHammerSmack;
7350 3 break;
7351
7352 case iCByrna:
7353 3 tempitem.power=1;
7354 3 tempitem.wpn=wCBYRNA;
7355 3 tempitem.wpn2=wCBYRNASLASH;
7356 3 tempitem.wpn3=wCBYRNAORB;
7357 3 tempitem.misc1=4;
7358 3 tempitem.misc2=16;
7359 3 tempitem.misc3=1;
7360 3 tempitem.cost_amount[0]=1;
7361 3 break;
7362
7363 case iWhistle:
7364 3 tempitem.wpn=wWIND;
7365 3 tempitem.misc1=3;
7366 3 tempitem.flags|=ITEM_FLAG1;
7367 3 break;
7368
7369 case iBRing:
7370 3 tempitem.power=2;
7371 3 tempitem.misc1=spBLUE;
7372 3 break;
7373
7374 case iRRing:
7375 3 tempitem.power=4;
7376 3 tempitem.misc1=spRED;
7377 3 break;
7378
7379 case iGRing:
7380 3 tempitem.power=8;
7381 3 tempitem.misc1=spGOLD;
7382 3 break;
7383
7384 case iSpinScroll:
7385 3 tempitem.power = 2;
7386 3 tempitem.misc1 = 1;
7387 3 break;
7388
7389 case iL2SpinScroll:
7390 3 tempitem.family=itype_spinscroll2;
7391 3 tempitem.fam_type=1;
7392 3 tempitem.cost_amount[0]=8;
7393 3 tempitem.power=2;
7394 3 tempitem.misc1 = 20;
7395 3 break;
7396
7397 case iQuakeScroll:
7398 3 tempitem.misc1=0x10;
7399 3 tempitem.misc2=64;
7400 3 break;
7401
7402 case iL2QuakeScroll:
7403 3 tempitem.family=itype_quakescroll2;
7404 3 tempitem.fam_type=1;
7405 3 tempitem.power = 2;
7406 3 tempitem.misc1=0x20;
7407 3 tempitem.misc2=192;
7408 3 tempitem.cost_amount[0]=8;
7409 3 break;
7410
7411 case iChargeRing:
7412 3 tempitem.misc1=64;
7413 3 tempitem.misc2=128;
7414 3 break;
7415
7416 case iL2ChargeRing:
7417 3 tempitem.misc1=32;
7418 3 tempitem.misc2=64;
7419 3 break;
7420
7421 case iOldGlove:
7422 3 tempitem.flags |= ITEM_FLAG1;
7423
7424 //fallthrough
7425 case iBombBagL4:
7426 case iWalletL3:
7427 case iQuiverL4:
7428 case iBracelet:
7429 15 tempitem.power = 1;
7430 15 break;
7431
7432 case iL2Bracelet:
7433 3 tempitem.power = 2;
7434 3 break;
7435
7436 case iMKey:
7437 3 tempitem.power=0xFF;
7438 3 tempitem.flags |= ITEM_FLAG1;
7439 3 break;
7440 }
7441 768 }
7442
7443
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 7)
7444 {
7445
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 756 times.
768 switch(i)
7446 {
7447 case iStoneAgony:
7448 case iStompBoots:
7449 case iPerilRing:
7450 case iWhimsicalRing:
7451 {
7452 12 reset_itembuf(&tempitem, i);
7453 12 strcpy(item_string[i],old_item_string[i]);
7454 12 break;
7455 }
7456 }
7457 768 }
7458
7459
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 8) // May 2007: Some corrections.
7460 {
7461
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 744 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
768 switch(i)
7462 {
7463 case iMShield:
7464 3 tempitem.misc1|=shFLAME;
7465 3 tempitem.misc2|=shFIREBALL|shMAGIC;
7466
7467
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules, qr_SWORDMIRROR))
7468 {
7469 tempitem.misc2 |= shSWORD;
7470 }
7471
7472 // fallthrough
7473 case iShield:
7474 6 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7475
7476 // fallthrough
7477 case iSShield:
7478 9 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7479
7480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7481 {
7482 tempitem.misc2 |= shROCK;
7483 }
7484
7485 9 break;
7486
7487 case iWhispRing:
7488 3 tempitem.power=1;
7489 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7490 3 tempitem.misc1 = 3;
7491 3 break;
7492
7493 case iL2WhispRing:
7494 3 tempitem.power=0;
7495 3 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7496 3 tempitem.misc1 = 3;
7497 3 break;
7498
7499 case iL2Ladder:
7500 case iBow:
7501 case iCByrna:
7502 9 tempitem.power = 1;
7503 9 break;
7504 }
7505 768 }
7506
7507
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 9 && i==iClock)
7508 {
7509 3 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7510 3 }
7511
7512 //add the misc flag for bomb
7513
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 765 times.
✓ Branch 3 taken 3 times.
25344 if(s_version < 10 && tempitem.family == itype_bomb)
7514 {
7515 3 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7516 3 }
7517
7518
4/4
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 24576 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 6 times.
25344 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7519 {
7520 6 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7521 6 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7522 6 }
7523
7524
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 12) // June 2007: More Misc. attributes.
7525 {
7526
5/5
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 753 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
768 switch(i)
7527 {
7528 case iFBrang:
7529 3 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7530
7531 //fallthrough
7532 case iMBrang:
7533 6 tempitem.misc3 |= shSWORD|shMAGIC;
7534
7535 //fallthrough
7536 case iHookshot:
7537 case iLongshot:
7538 //fallthrough
7539 12 tempitem.misc3 |= shFIREBALL;
7540
7541 case iBrang:
7542 15 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7543 15 break;
7544 }
7545
7546
16/16
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 282 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 411 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 14 taken 3 times.
✓ Branch 15 taken 3 times.
768 switch(tempitem.family)
7547 {
7548 case itype_hoverboots:
7549 3 tempitem.usesound = WAV_ZN1HOVER;
7550 3 break;
7551
7552 case itype_wand:
7553 3 tempitem.usesound = WAV_WAND;
7554 3 break;
7555
7556 case itype_book:
7557 3 tempitem.usesound = WAV_FIRE;
7558 3 break;
7559
7560 case itype_arrow:
7561 9 tempitem.usesound = WAV_ARROW;
7562 9 break;
7563
7564 case itype_hookshot:
7565 6 tempitem.usesound = WAV_HOOKSHOT;
7566 6 break;
7567
7568 case itype_brang:
7569 9 tempitem.usesound = WAV_BRANG;
7570 9 break;
7571
7572 case itype_shield:
7573 9 tempitem.usesound = WAV_CHINK;
7574 9 break;
7575
7576 case itype_sword:
7577 411 tempitem.usesound = WAV_SWORD;
7578 411 break;
7579
7580 case itype_whistle:
7581 3 tempitem.usesound = WAV_WHISTLE;
7582 3 break;
7583
7584 case itype_hammer:
7585 3 tempitem.usesound = WAV_HAMMER;
7586 3 break;
7587
7588 case itype_dinsfire:
7589 3 tempitem.usesound = WAV_ZN1DINSFIRE;
7590 3 break;
7591
7592 case itype_faroreswind:
7593 3 tempitem.usesound = WAV_ZN1FARORESWIND;
7594 3 break;
7595
7596 case itype_nayruslove:
7597 3 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7598 3 break;
7599
7600 case itype_bomb:
7601 case itype_sbomb:
7602 case itype_quakescroll:
7603 case itype_quakescroll2:
7604 12 tempitem.usesound = WAV_BOMB;
7605 12 break;
7606
7607 case itype_spinscroll:
7608 case itype_spinscroll2:
7609 6 tempitem.usesound = WAV_ZN1SPINATTACK;
7610 6 break;
7611 }
7612 768 }
7613
7614
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 13) // July 2007
7615 {
7616
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7617 {
7618 3 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7619 3 tempitem.power = 1;
7620 3 tempitem.flags|=ITEM_FLAG1;
7621 3 }
7622
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_wand)
7623 3 tempitem.flags|=ITEM_FLAG1;
7624
2/2
✓ Branch 0 taken 759 times.
✓ Branch 1 taken 3 times.
762 else if(tempitem.family == itype_book)
7625 {
7626 3 tempitem.flags|=ITEM_FLAG1;
7627 3 tempitem.power = 2;
7628 3 }
7629 768 }
7630
7631
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 14) // August 2007
7632 {
7633
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
768 if(tempitem.family == itype_fairy)
7634 {
7635 6 tempitem.usesound = WAV_SCALE;
7636
7637
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tempitem.fam_type)
7638 6 tempitem.misc3=50;
7639 6 }
7640
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_potion)
7641 {
7642 6 tempitem.flags |= ITEM_GAINOLD;
7643 6 }
7644 768 }
7645
7646
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 17) // November 2007
7647 {
7648
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
768 if(tempitem.family == itype_candle && !tempitem.wpn3)
7649 {
7650 tempitem.wpn3 = wFIRE;
7651 }
7652
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 759 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 3 times.
768 else if(tempitem.family == itype_arrow && tempitem.power>4)
7653 {
7654 3 tempitem.flags|=ITEM_FLAG1;
7655 3 }
7656 768 }
7657
7658
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 18) // New Year's Eve 2007
7659 {
7660
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_whistle)
7661 3 tempitem.misc2 = 8; // Use the Whistle warp ring
7662
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 762 times.
765 else if(tempitem.family == itype_bait)
7663 3 tempitem.misc1 = 768; // Frames until it goes
7664
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 6 times.
762 else if(tempitem.family == itype_triforcepiece)
7665 {
7666
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(tempitem.flags & ITEM_GAMEDATA)
7667 {
7668 3 tempitem.misc2 = 1; // Cutscene 1
7669 3 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7670 3 }
7671 6 }
7672 768 }
7673
7674
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 19) // January 2008
7675 {
7676
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_nayruslove)
7677 {
7678 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7679 3 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7680 3 }
7681 768 }
7682
7683
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 20) // October 2008
7684 {
7685
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_nayruslove)
7686 {
7687 3 tempitem.wpn6=wNAYRUSLOVE2A;
7688 3 tempitem.wpn7=wNAYRUSLOVE2B;
7689 3 tempitem.wpn8=wNAYRUSLOVES2A;
7690 3 tempitem.wpn9=wNAYRUSLOVES2B;
7691 3 tempitem.wpn5 = iwNayrusLoveShieldFront;
7692 3 tempitem.wpn10 = iwNayrusLoveShieldBack;
7693 3 }
7694 768 }
7695
7696
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 21) // November 2008
7697 {
7698
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(tempitem.flags & 0x0100) // ITEM_SLASH
7699 {
7700 tempitem.flags &= ~0x0100;
7701
7702 if(tempitem.family == itype_sword ||
7703 tempitem.family == itype_wand ||
7704 tempitem.family == itype_candle ||
7705 tempitem.family == itype_cbyrna)
7706 {
7707 tempitem.flags |= ITEM_FLAG4;
7708 }
7709 }
7710 768 }
7711
7712
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 22) // September 2009
7713 {
7714
4/4
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 762 times.
768 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7715 {
7716 6 tempitem.misc3 = tempitem.power/2;
7717 6 }
7718 768 }
7719
7720
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 23) // March 2011
7721 {
7722
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 765 times.
768 if(tempitem.family == itype_dinsfire)
7723 3 tempitem.wpn5 = wFIRE;
7724
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 3 times.
765 else if(tempitem.family == itype_book)
7725 3 tempitem.wpn2 = wFIRE;
7726 768 }
7727
7728 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7729 // whether it was or not, and a lot of existing quests depended on the
7730 // incorrect behavior.
7731
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 768 times.
25344 if(s_version < 25) // January 2012
7732 {
7733
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 12 times.
768 if(tempitem.family == itype_bombbag)
7734 12 tempitem.flags |= 16;
7735
7736
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 3 times.
768 if(tempitem.family == itype_dinsfire)
7737 3 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7738 768 }
7739
7740
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7741 {
7742
60/60
✓ Branch 0 taken 2017 times.
✓ Branch 1 taken 827 times.
✓ Branch 2 taken 231 times.
✓ Branch 3 taken 970 times.
✓ Branch 4 taken 2157 times.
✓ Branch 5 taken 6474 times.
✓ Branch 6 taken 231 times.
✓ Branch 7 taken 229 times.
✓ Branch 8 taken 192 times.
✓ Branch 9 taken 123 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 154 times.
✓ Branch 12 taken 153 times.
✓ Branch 13 taken 92 times.
✓ Branch 14 taken 231 times.
✓ Branch 15 taken 231 times.
✓ Branch 16 taken 152 times.
✓ Branch 17 taken 231 times.
✓ Branch 18 taken 154 times.
✓ Branch 19 taken 77 times.
✓ Branch 20 taken 154 times.
✓ Branch 21 taken 92 times.
✓ Branch 22 taken 77 times.
✓ Branch 23 taken 231 times.
✓ Branch 24 taken 77 times.
✓ Branch 25 taken 77 times.
✓ Branch 26 taken 154 times.
✓ Branch 27 taken 77 times.
✓ Branch 28 taken 77 times.
✓ Branch 29 taken 77 times.
✓ Branch 30 taken 77 times.
✓ Branch 31 taken 77 times.
✓ Branch 32 taken 92 times.
✓ Branch 33 taken 77 times.
✓ Branch 34 taken 77 times.
✓ Branch 35 taken 77 times.
✓ Branch 36 taken 77 times.
✓ Branch 37 taken 154 times.
✓ Branch 38 taken 308 times.
✓ Branch 39 taken 77 times.
✓ Branch 40 taken 77 times.
✓ Branch 41 taken 136 times.
✓ Branch 42 taken 308 times.
✓ Branch 43 taken 77 times.
✓ Branch 44 taken 77 times.
✓ Branch 45 taken 77 times.
✓ Branch 46 taken 77 times.
✓ Branch 47 taken 77 times.
✓ Branch 48 taken 154 times.
✓ Branch 49 taken 154 times.
✓ Branch 50 taken 77 times.
✓ Branch 51 taken 231 times.
✓ Branch 52 taken 231 times.
✓ Branch 53 taken 308 times.
✓ Branch 54 taken 77 times.
✓ Branch 55 taken 77 times.
✓ Branch 56 taken 77 times.
✓ Branch 57 taken 77 times.
✓ Branch 58 taken 77 times.
✓ Branch 59 taken 77 times.
19712 switch(tempitem.family)
7743 {
7744 case itype_sword:
7745 {
7746 6474 tempitem.flags &= ~(ITEM_FLAG5);
7747 6474 tempitem.misc3 = 0;
7748 6474 tempitem.misc4 = 0;
7749 6474 tempitem.misc5 = 0;
7750 6474 tempitem.misc6 = 0;
7751 6474 tempitem.misc7 = 0;
7752 6474 tempitem.misc8 = 0;
7753 6474 tempitem.misc9 = 0;
7754 6474 tempitem.misc10 = 0;
7755 6474 tempitem.wpn4 = 0;
7756 6474 tempitem.wpn5 = 0;
7757 6474 tempitem.wpn6 = 0;
7758 6474 tempitem.wpn7 = 0;
7759 6474 tempitem.wpn8 = 0;
7760 6474 tempitem.wpn9 = 0;
7761 6474 tempitem.wpn10 = 0;
7762 6474 break;
7763 }
7764 case itype_brang:
7765 {
7766 231 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7767 231 tempitem.misc2 = 0;
7768 231 tempitem.misc5 = 0;
7769 231 tempitem.misc6 = 0;
7770 231 tempitem.misc7 = 0;
7771 231 tempitem.misc8 = 0;
7772 231 tempitem.misc9 = 0;
7773 231 tempitem.misc10 = 0;
7774 231 tempitem.wpn4 = 0;
7775 231 tempitem.wpn5 = 0;
7776 231 tempitem.wpn6 = 0;
7777 231 tempitem.wpn7 = 0;
7778 231 tempitem.wpn8 = 0;
7779 231 tempitem.wpn9 = 0;
7780 231 tempitem.wpn10 = 0;
7781 231 break;
7782 }
7783 case itype_arrow:
7784 {
7785 229 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7786 229 tempitem.misc2 = 0;
7787 229 tempitem.misc3 = 0;
7788 229 tempitem.misc4 = 0;
7789 229 tempitem.misc5 = 0;
7790 229 tempitem.misc6 = 0;
7791 229 tempitem.misc7 = 0;
7792 229 tempitem.misc8 = 0;
7793 229 tempitem.misc9 = 0;
7794 229 tempitem.misc10 = 0;
7795 229 tempitem.wpn4 = 0;
7796 229 tempitem.wpn5 = 0;
7797 229 tempitem.wpn6 = 0;
7798 229 tempitem.wpn7 = 0;
7799 229 tempitem.wpn8 = 0;
7800 229 tempitem.wpn9 = 0;
7801 229 tempitem.wpn10 = 0;
7802 229 break;
7803 }
7804 case itype_candle:
7805 {
7806 192 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7807 192 tempitem.misc1 = 0;
7808 192 tempitem.misc2 = 0;
7809 192 tempitem.misc3 = 0;
7810 192 tempitem.misc4 = 0;
7811 192 tempitem.misc5 = 0;
7812 192 tempitem.misc6 = 0;
7813 192 tempitem.misc7 = 0;
7814 192 tempitem.misc8 = 0;
7815 192 tempitem.misc9 = 0;
7816 192 tempitem.misc10 = 0;
7817 192 tempitem.wpn4 = 0;
7818 192 tempitem.wpn5 = 0;
7819 192 tempitem.wpn6 = 0;
7820 192 tempitem.wpn7 = 0;
7821 192 tempitem.wpn8 = 0;
7822 192 tempitem.wpn9 = 0;
7823 192 tempitem.wpn10 = 0;
7824 192 break;
7825 }
7826 case itype_whistle:
7827 {
7828 123 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7829 123 tempitem.misc3 = 0;
7830 123 tempitem.misc4 = 0;
7831 123 tempitem.misc5 = 0;
7832 123 tempitem.misc6 = 0;
7833 123 tempitem.misc7 = 0;
7834 123 tempitem.misc8 = 0;
7835 123 tempitem.misc9 = 0;
7836 123 tempitem.misc10 = 0;
7837 123 tempitem.wpn2 = 0;
7838 123 tempitem.wpn3 = 0;
7839 123 tempitem.wpn4 = 0;
7840 123 tempitem.wpn5 = 0;
7841 123 tempitem.wpn6 = 0;
7842 123 tempitem.wpn7 = 0;
7843 123 tempitem.wpn8 = 0;
7844 123 tempitem.wpn9 = 0;
7845 123 tempitem.wpn10 = 0;
7846 123 break;
7847 }
7848 case itype_bait:
7849 {
7850 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7851 77 tempitem.misc2 = 0;
7852 77 tempitem.misc3 = 0;
7853 77 tempitem.misc4 = 0;
7854 77 tempitem.misc5 = 0;
7855 77 tempitem.misc6 = 0;
7856 77 tempitem.misc7 = 0;
7857 77 tempitem.misc8 = 0;
7858 77 tempitem.misc9 = 0;
7859 77 tempitem.misc10 = 0;
7860 77 tempitem.wpn2 = 0;
7861 77 tempitem.wpn3 = 0;
7862 77 tempitem.wpn4 = 0;
7863 77 tempitem.wpn5 = 0;
7864 77 tempitem.wpn6 = 0;
7865 77 tempitem.wpn7 = 0;
7866 77 tempitem.wpn8 = 0;
7867 77 tempitem.wpn9 = 0;
7868 77 tempitem.wpn10 = 0;
7869 77 break;
7870 }
7871 case itype_letter:
7872 {
7873 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7874 154 tempitem.misc1 = 0;
7875 154 tempitem.misc2 = 0;
7876 154 tempitem.misc3 = 0;
7877 154 tempitem.misc4 = 0;
7878 154 tempitem.misc5 = 0;
7879 154 tempitem.misc6 = 0;
7880 154 tempitem.misc7 = 0;
7881 154 tempitem.misc8 = 0;
7882 154 tempitem.misc9 = 0;
7883 154 tempitem.misc10 = 0;
7884 154 tempitem.wpn = 0;
7885 154 tempitem.wpn2 = 0;
7886 154 tempitem.wpn3 = 0;
7887 154 tempitem.wpn4 = 0;
7888 154 tempitem.wpn5 = 0;
7889 154 tempitem.wpn6 = 0;
7890 154 tempitem.wpn7 = 0;
7891 154 tempitem.wpn8 = 0;
7892 154 tempitem.wpn9 = 0;
7893 154 tempitem.wpn10 = 0;
7894 154 break;
7895 }
7896 case itype_potion:
7897 {
7898 153 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7899 153 tempitem.misc3 = 0;
7900 153 tempitem.misc4 = 0;
7901 153 tempitem.misc5 = 0;
7902 153 tempitem.misc6 = 0;
7903 153 tempitem.misc7 = 0;
7904 153 tempitem.misc8 = 0;
7905 153 tempitem.misc9 = 0;
7906 153 tempitem.misc10 = 0;
7907 153 tempitem.wpn = 0;
7908 153 tempitem.wpn2 = 0;
7909 153 tempitem.wpn3 = 0;
7910 153 tempitem.wpn4 = 0;
7911 153 tempitem.wpn5 = 0;
7912 153 tempitem.wpn6 = 0;
7913 153 tempitem.wpn7 = 0;
7914 153 tempitem.wpn8 = 0;
7915 153 tempitem.wpn9 = 0;
7916 153 tempitem.wpn10 = 0;
7917 153 break;
7918 }
7919 case itype_wand:
7920 {
7921 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7922 92 tempitem.misc1 = 0;
7923 92 tempitem.misc2 = 0;
7924 92 tempitem.misc3 = 0;
7925 92 tempitem.misc4 = 0;
7926 92 tempitem.misc5 = 0;
7927 92 tempitem.misc6 = 0;
7928 92 tempitem.misc7 = 0;
7929 92 tempitem.misc8 = 0;
7930 92 tempitem.misc9 = 0;
7931 92 tempitem.misc10 = 0;
7932 92 tempitem.wpn4 = 0;
7933 92 tempitem.wpn5 = 0;
7934 92 tempitem.wpn6 = 0;
7935 92 tempitem.wpn7 = 0;
7936 92 tempitem.wpn8 = 0;
7937 92 tempitem.wpn9 = 0;
7938 92 tempitem.wpn10 = 0;
7939 92 break;
7940 }
7941 case itype_ring:
7942 {
7943 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7944 231 tempitem.misc2 = 0;
7945 231 tempitem.misc3 = 0;
7946 231 tempitem.misc4 = 0;
7947 231 tempitem.misc5 = 0;
7948 231 tempitem.misc6 = 0;
7949 231 tempitem.misc7 = 0;
7950 231 tempitem.misc8 = 0;
7951 231 tempitem.misc9 = 0;
7952 231 tempitem.misc10 = 0;
7953 231 tempitem.wpn = 0;
7954 231 tempitem.wpn2 = 0;
7955 231 tempitem.wpn3 = 0;
7956 231 tempitem.wpn4 = 0;
7957 231 tempitem.wpn5 = 0;
7958 231 tempitem.wpn6 = 0;
7959 231 tempitem.wpn7 = 0;
7960 231 tempitem.wpn8 = 0;
7961 231 tempitem.wpn9 = 0;
7962 231 tempitem.wpn10 = 0;
7963 231 break;
7964 }
7965 case itype_wallet:
7966 {
7967 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7968 231 tempitem.misc3 = 0;
7969 231 tempitem.misc4 = 0;
7970 231 tempitem.misc5 = 0;
7971 231 tempitem.misc6 = 0;
7972 231 tempitem.misc7 = 0;
7973 231 tempitem.misc8 = 0;
7974 231 tempitem.misc9 = 0;
7975 231 tempitem.misc10 = 0;
7976 231 tempitem.wpn = 0;
7977 231 tempitem.wpn2 = 0;
7978 231 tempitem.wpn3 = 0;
7979 231 tempitem.wpn4 = 0;
7980 231 tempitem.wpn5 = 0;
7981 231 tempitem.wpn6 = 0;
7982 231 tempitem.wpn7 = 0;
7983 231 tempitem.wpn8 = 0;
7984 231 tempitem.wpn9 = 0;
7985 231 tempitem.wpn10 = 0;
7986 231 break;
7987 }
7988 case itype_amulet:
7989 {
7990 152 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7991 152 tempitem.misc1 = 0;
7992 152 tempitem.misc2 = 0;
7993 152 tempitem.misc3 = 0;
7994 152 tempitem.misc4 = 0;
7995 152 tempitem.misc5 = 0;
7996 152 tempitem.misc6 = 0;
7997 152 tempitem.misc7 = 0;
7998 152 tempitem.misc8 = 0;
7999 152 tempitem.misc9 = 0;
8000 152 tempitem.misc10 = 0;
8001 152 tempitem.wpn = 0;
8002 152 tempitem.wpn2 = 0;
8003 152 tempitem.wpn3 = 0;
8004 152 tempitem.wpn4 = 0;
8005 152 tempitem.wpn5 = 0;
8006 152 tempitem.wpn6 = 0;
8007 152 tempitem.wpn7 = 0;
8008 152 tempitem.wpn8 = 0;
8009 152 tempitem.wpn9 = 0;
8010 152 tempitem.wpn10 = 0;
8011 152 break;
8012 }
8013 case itype_shield:
8014 {
8015 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8016 231 tempitem.misc3 = 0;
8017 231 tempitem.misc4 = 0;
8018 231 tempitem.misc5 = 0;
8019 231 tempitem.misc6 = 0;
8020 231 tempitem.misc7 = 0;
8021 231 tempitem.misc8 = 0;
8022 231 tempitem.misc9 = 0;
8023 231 tempitem.misc10 = 0;
8024 231 tempitem.wpn = 0;
8025 231 tempitem.wpn2 = 0;
8026 231 tempitem.wpn3 = 0;
8027 231 tempitem.wpn4 = 0;
8028 231 tempitem.wpn5 = 0;
8029 231 tempitem.wpn6 = 0;
8030 231 tempitem.wpn7 = 0;
8031 231 tempitem.wpn8 = 0;
8032 231 tempitem.wpn9 = 0;
8033 231 tempitem.wpn10 = 0;
8034 231 break;
8035 }
8036 case itype_bow:
8037 {
8038 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8039 154 tempitem.misc1 = 0;
8040 154 tempitem.misc2 = 0;
8041 154 tempitem.misc3 = 0;
8042 154 tempitem.misc4 = 0;
8043 154 tempitem.misc5 = 0;
8044 154 tempitem.misc6 = 0;
8045 154 tempitem.misc7 = 0;
8046 154 tempitem.misc8 = 0;
8047 154 tempitem.misc9 = 0;
8048 154 tempitem.misc10 = 0;
8049 154 tempitem.wpn = 0;
8050 154 tempitem.wpn2 = 0;
8051 154 tempitem.wpn3 = 0;
8052 154 tempitem.wpn4 = 0;
8053 154 tempitem.wpn5 = 0;
8054 154 tempitem.wpn6 = 0;
8055 154 tempitem.wpn7 = 0;
8056 154 tempitem.wpn8 = 0;
8057 154 tempitem.wpn9 = 0;
8058 154 tempitem.wpn10 = 0;
8059 154 break;
8060 }
8061 case itype_raft:
8062 {
8063 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8064 77 tempitem.misc1 = 0;
8065 77 tempitem.misc2 = 0;
8066 77 tempitem.misc3 = 0;
8067 77 tempitem.misc4 = 0;
8068 77 tempitem.misc5 = 0;
8069 77 tempitem.misc6 = 0;
8070 77 tempitem.misc7 = 0;
8071 77 tempitem.misc8 = 0;
8072 77 tempitem.misc9 = 0;
8073 77 tempitem.misc10 = 0;
8074 77 tempitem.wpn = 0;
8075 77 tempitem.wpn2 = 0;
8076 77 tempitem.wpn3 = 0;
8077 77 tempitem.wpn4 = 0;
8078 77 tempitem.wpn5 = 0;
8079 77 tempitem.wpn6 = 0;
8080 77 tempitem.wpn7 = 0;
8081 77 tempitem.wpn8 = 0;
8082 77 tempitem.wpn9 = 0;
8083 77 tempitem.wpn10 = 0;
8084 77 break;
8085 }
8086 case itype_ladder:
8087 {
8088 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8089 154 tempitem.misc1 = 0;
8090 154 tempitem.misc2 = 0;
8091 154 tempitem.misc3 = 0;
8092 154 tempitem.misc4 = 0;
8093 154 tempitem.misc5 = 0;
8094 154 tempitem.misc6 = 0;
8095 154 tempitem.misc7 = 0;
8096 154 tempitem.misc8 = 0;
8097 154 tempitem.misc9 = 0;
8098 154 tempitem.misc10 = 0;
8099 154 tempitem.wpn = 0;
8100 154 tempitem.wpn2 = 0;
8101 154 tempitem.wpn3 = 0;
8102 154 tempitem.wpn4 = 0;
8103 154 tempitem.wpn5 = 0;
8104 154 tempitem.wpn6 = 0;
8105 154 tempitem.wpn7 = 0;
8106 154 tempitem.wpn8 = 0;
8107 154 tempitem.wpn9 = 0;
8108 154 tempitem.wpn10 = 0;
8109 154 break;
8110 }
8111 case itype_book:
8112 {
8113 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8114 92 tempitem.misc1 = 0;
8115 92 tempitem.misc2 = 0;
8116 92 tempitem.misc3 = 0;
8117 92 tempitem.misc4 = 0;
8118 92 tempitem.misc5 = 0;
8119 92 tempitem.misc6 = 0;
8120 92 tempitem.misc7 = 0;
8121 92 tempitem.misc8 = 0;
8122 92 tempitem.misc9 = 0;
8123 92 tempitem.misc10 = 0;
8124 92 tempitem.wpn3 = 0;
8125 92 tempitem.wpn4 = 0;
8126 92 tempitem.wpn5 = 0;
8127 92 tempitem.wpn6 = 0;
8128 92 tempitem.wpn7 = 0;
8129 92 tempitem.wpn8 = 0;
8130 92 tempitem.wpn9 = 0;
8131 92 tempitem.wpn10 = 0;
8132 92 break;
8133 }
8134 case itype_magickey:
8135 {
8136 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8137 77 tempitem.misc1 = 0;
8138 77 tempitem.misc2 = 0;
8139 77 tempitem.misc3 = 0;
8140 77 tempitem.misc4 = 0;
8141 77 tempitem.misc5 = 0;
8142 77 tempitem.misc6 = 0;
8143 77 tempitem.misc7 = 0;
8144 77 tempitem.misc8 = 0;
8145 77 tempitem.misc9 = 0;
8146 77 tempitem.misc10 = 0;
8147 77 tempitem.wpn = 0;
8148 77 tempitem.wpn2 = 0;
8149 77 tempitem.wpn3 = 0;
8150 77 tempitem.wpn4 = 0;
8151 77 tempitem.wpn5 = 0;
8152 77 tempitem.wpn6 = 0;
8153 77 tempitem.wpn7 = 0;
8154 77 tempitem.wpn8 = 0;
8155 77 tempitem.wpn9 = 0;
8156 77 tempitem.wpn10 = 0;
8157 77 break;
8158 }
8159 case itype_bracelet:
8160 {
8161 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8162 231 tempitem.misc1 = 0;
8163 231 tempitem.misc2 = 0;
8164 231 tempitem.misc3 = 0;
8165 231 tempitem.misc4 = 0;
8166 231 tempitem.misc5 = 0;
8167 231 tempitem.misc6 = 0;
8168 231 tempitem.misc7 = 0;
8169 231 tempitem.misc8 = 0;
8170 231 tempitem.misc9 = 0;
8171 231 tempitem.misc10 = 0;
8172 231 tempitem.wpn = 0;
8173 231 tempitem.wpn2 = 0;
8174 231 tempitem.wpn3 = 0;
8175 231 tempitem.wpn4 = 0;
8176 231 tempitem.wpn5 = 0;
8177 231 tempitem.wpn6 = 0;
8178 231 tempitem.wpn7 = 0;
8179 231 tempitem.wpn8 = 0;
8180 231 tempitem.wpn9 = 0;
8181 231 tempitem.wpn10 = 0;
8182 231 break;
8183 }
8184 case itype_flippers:
8185 {
8186 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8187 77 tempitem.misc1 = 0;
8188 77 tempitem.misc2 = 0;
8189 77 tempitem.misc3 = 0;
8190 77 tempitem.misc4 = 0;
8191 77 tempitem.misc5 = 0;
8192 77 tempitem.misc6 = 0;
8193 77 tempitem.misc7 = 0;
8194 77 tempitem.misc8 = 0;
8195 77 tempitem.misc9 = 0;
8196 77 tempitem.misc10 = 0;
8197 77 tempitem.wpn = 0;
8198 77 tempitem.wpn2 = 0;
8199 77 tempitem.wpn3 = 0;
8200 77 tempitem.wpn4 = 0;
8201 77 tempitem.wpn5 = 0;
8202 77 tempitem.wpn6 = 0;
8203 77 tempitem.wpn7 = 0;
8204 77 tempitem.wpn8 = 0;
8205 77 tempitem.wpn9 = 0;
8206 77 tempitem.wpn10 = 0;
8207 77 break;
8208 }
8209 case itype_boots:
8210 {
8211 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8212 77 tempitem.misc1 = 0;
8213 77 tempitem.misc2 = 0;
8214 77 tempitem.misc3 = 0;
8215 77 tempitem.misc4 = 0;
8216 77 tempitem.misc5 = 0;
8217 77 tempitem.misc6 = 0;
8218 77 tempitem.misc7 = 0;
8219 77 tempitem.misc8 = 0;
8220 77 tempitem.misc9 = 0;
8221 77 tempitem.misc10 = 0;
8222 77 tempitem.wpn = 0;
8223 77 tempitem.wpn2 = 0;
8224 77 tempitem.wpn3 = 0;
8225 77 tempitem.wpn4 = 0;
8226 77 tempitem.wpn5 = 0;
8227 77 tempitem.wpn6 = 0;
8228 77 tempitem.wpn7 = 0;
8229 77 tempitem.wpn8 = 0;
8230 77 tempitem.wpn9 = 0;
8231 77 tempitem.wpn10 = 0;
8232 77 break;
8233 }
8234 case itype_hookshot:
8235 {
8236 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8237 154 tempitem.misc5 = 0;
8238 154 tempitem.misc6 = 0;
8239 154 tempitem.misc7 = 0;
8240 154 tempitem.misc8 = 0;
8241 154 tempitem.misc9 = 0;
8242 154 tempitem.misc10 = 0;
8243 154 tempitem.wpn5 = 0;
8244 154 tempitem.wpn6 = 0;
8245 154 tempitem.wpn7 = 0;
8246 154 tempitem.wpn8 = 0;
8247 154 tempitem.wpn9 = 0;
8248 154 tempitem.wpn10 = 0;
8249 154 break;
8250 }
8251 case itype_lens:
8252 {
8253 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8254 77 tempitem.misc2 = 0;
8255 77 tempitem.misc3 = 0;
8256 77 tempitem.misc4 = 0;
8257 77 tempitem.misc5 = 0;
8258 77 tempitem.misc6 = 0;
8259 77 tempitem.misc7 = 0;
8260 77 tempitem.misc8 = 0;
8261 77 tempitem.misc9 = 0;
8262 77 tempitem.misc10 = 0;
8263 77 tempitem.wpn = 0;
8264 77 tempitem.wpn2 = 0;
8265 77 tempitem.wpn3 = 0;
8266 77 tempitem.wpn4 = 0;
8267 77 tempitem.wpn5 = 0;
8268 77 tempitem.wpn6 = 0;
8269 77 tempitem.wpn7 = 0;
8270 77 tempitem.wpn8 = 0;
8271 77 tempitem.wpn9 = 0;
8272 77 tempitem.wpn10 = 0;
8273 77 break;
8274 }
8275 case itype_hammer:
8276 {
8277 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8278 77 tempitem.misc1 = 0;
8279 77 tempitem.misc2 = 0;
8280 77 tempitem.misc3 = 0;
8281 77 tempitem.misc4 = 0;
8282 77 tempitem.misc5 = 0;
8283 77 tempitem.misc6 = 0;
8284 77 tempitem.misc7 = 0;
8285 77 tempitem.misc8 = 0;
8286 77 tempitem.misc9 = 0;
8287 77 tempitem.misc10 = 0;
8288 77 tempitem.wpn3 = 0;
8289 77 tempitem.wpn4 = 0;
8290 77 tempitem.wpn5 = 0;
8291 77 tempitem.wpn6 = 0;
8292 77 tempitem.wpn7 = 0;
8293 77 tempitem.wpn8 = 0;
8294 77 tempitem.wpn9 = 0;
8295 77 tempitem.wpn10 = 0;
8296 77 break;
8297 }
8298 case itype_dinsfire:
8299 {
8300 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8301 77 tempitem.misc3 = 0;
8302 77 tempitem.misc4 = 0;
8303 77 tempitem.misc5 = 0;
8304 77 tempitem.misc6 = 0;
8305 77 tempitem.misc7 = 0;
8306 77 tempitem.misc8 = 0;
8307 77 tempitem.misc9 = 0;
8308 77 tempitem.misc10 = 0;
8309 77 tempitem.wpn6 = 0;
8310 77 tempitem.wpn7 = 0;
8311 77 tempitem.wpn8 = 0;
8312 77 tempitem.wpn9 = 0;
8313 77 tempitem.wpn10 = 0;
8314 77 break;
8315 }
8316 case itype_faroreswind:
8317 {
8318 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8319 77 tempitem.misc2 = 0;
8320 77 tempitem.misc3 = 0;
8321 77 tempitem.misc4 = 0;
8322 77 tempitem.misc5 = 0;
8323 77 tempitem.misc6 = 0;
8324 77 tempitem.misc7 = 0;
8325 77 tempitem.misc8 = 0;
8326 77 tempitem.misc9 = 0;
8327 77 tempitem.misc10 = 0;
8328 77 tempitem.wpn = 0;
8329 77 tempitem.wpn2 = 0;
8330 77 tempitem.wpn3 = 0;
8331 77 tempitem.wpn4 = 0;
8332 77 tempitem.wpn5 = 0;
8333 77 tempitem.wpn6 = 0;
8334 77 tempitem.wpn7 = 0;
8335 77 tempitem.wpn8 = 0;
8336 77 tempitem.wpn9 = 0;
8337 77 tempitem.wpn10 = 0;
8338 77 break;
8339 }
8340 case itype_nayruslove:
8341 {
8342 77 tempitem.flags &= ~ (ITEM_FLAG5);
8343 77 tempitem.misc2 = 0;
8344 77 tempitem.misc3 = 0;
8345 77 tempitem.misc4 = 0;
8346 77 tempitem.misc5 = 0;
8347 77 tempitem.misc6 = 0;
8348 77 tempitem.misc7 = 0;
8349 77 tempitem.misc8 = 0;
8350 77 tempitem.misc9 = 0;
8351 77 tempitem.misc10 = 0;
8352 77 break;
8353 }
8354 case itype_bomb:
8355 {
8356 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8357 92 tempitem.misc4 = 0;
8358 92 tempitem.misc5 = 0;
8359 92 tempitem.misc6 = 0;
8360 92 tempitem.misc7 = 0;
8361 92 tempitem.misc8 = 0;
8362 92 tempitem.misc9 = 0;
8363 92 tempitem.misc10 = 0;
8364 92 tempitem.wpn3 = 0;
8365 92 tempitem.wpn4 = 0;
8366 92 tempitem.wpn5 = 0;
8367 92 tempitem.wpn6 = 0;
8368 92 tempitem.wpn7 = 0;
8369 92 tempitem.wpn8 = 0;
8370 92 tempitem.wpn9 = 0;
8371 92 tempitem.wpn10 = 0;
8372 92 break;
8373 }
8374 case itype_sbomb:
8375 {
8376 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8377 77 tempitem.misc4 = 0;
8378 77 tempitem.misc5 = 0;
8379 77 tempitem.misc6 = 0;
8380 77 tempitem.misc7 = 0;
8381 77 tempitem.misc8 = 0;
8382 77 tempitem.misc9 = 0;
8383 77 tempitem.misc10 = 0;
8384 77 tempitem.wpn3 = 0;
8385 77 tempitem.wpn4 = 0;
8386 77 tempitem.wpn5 = 0;
8387 77 tempitem.wpn6 = 0;
8388 77 tempitem.wpn7 = 0;
8389 77 tempitem.wpn8 = 0;
8390 77 tempitem.wpn9 = 0;
8391 77 tempitem.wpn10 = 0;
8392 77 break;
8393 }
8394 case itype_clock:
8395 {
8396 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8397 77 tempitem.misc2 = 0;
8398 77 tempitem.misc3 = 0;
8399 77 tempitem.misc4 = 0;
8400 77 tempitem.misc5 = 0;
8401 77 tempitem.misc6 = 0;
8402 77 tempitem.misc7 = 0;
8403 77 tempitem.misc8 = 0;
8404 77 tempitem.misc9 = 0;
8405 77 tempitem.misc10 = 0;
8406 77 tempitem.wpn = 0;
8407 77 tempitem.wpn2 = 0;
8408 77 tempitem.wpn3 = 0;
8409 77 tempitem.wpn4 = 0;
8410 77 tempitem.wpn5 = 0;
8411 77 tempitem.wpn6 = 0;
8412 77 tempitem.wpn7 = 0;
8413 77 tempitem.wpn8 = 0;
8414 77 tempitem.wpn9 = 0;
8415 77 tempitem.wpn10 = 0;
8416 77 break;
8417 }
8418 case itype_key:
8419 {
8420 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8421 77 tempitem.misc1 = 0;
8422 77 tempitem.misc2 = 0;
8423 77 tempitem.misc3 = 0;
8424 77 tempitem.misc4 = 0;
8425 77 tempitem.misc5 = 0;
8426 77 tempitem.misc6 = 0;
8427 77 tempitem.misc7 = 0;
8428 77 tempitem.misc8 = 0;
8429 77 tempitem.misc9 = 0;
8430 77 tempitem.misc10 = 0;
8431 77 tempitem.wpn = 0;
8432 77 tempitem.wpn2 = 0;
8433 77 tempitem.wpn3 = 0;
8434 77 tempitem.wpn4 = 0;
8435 77 tempitem.wpn5 = 0;
8436 77 tempitem.wpn6 = 0;
8437 77 tempitem.wpn7 = 0;
8438 77 tempitem.wpn8 = 0;
8439 77 tempitem.wpn9 = 0;
8440 77 tempitem.wpn10 = 0;
8441 77 break;
8442 }
8443 case itype_magiccontainer:
8444 {
8445 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8446 77 tempitem.misc1 = 0;
8447 77 tempitem.misc2 = 0;
8448 77 tempitem.misc3 = 0;
8449 77 tempitem.misc4 = 0;
8450 77 tempitem.misc5 = 0;
8451 77 tempitem.misc6 = 0;
8452 77 tempitem.misc7 = 0;
8453 77 tempitem.misc8 = 0;
8454 77 tempitem.misc9 = 0;
8455 77 tempitem.misc10 = 0;
8456 77 tempitem.wpn = 0;
8457 77 tempitem.wpn2 = 0;
8458 77 tempitem.wpn3 = 0;
8459 77 tempitem.wpn4 = 0;
8460 77 tempitem.wpn5 = 0;
8461 77 tempitem.wpn6 = 0;
8462 77 tempitem.wpn7 = 0;
8463 77 tempitem.wpn8 = 0;
8464 77 tempitem.wpn9 = 0;
8465 77 tempitem.wpn10 = 0;
8466 77 break;
8467 }
8468 case itype_triforcepiece:
8469 {
8470 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8471 154 tempitem.misc3 = 0;
8472 154 tempitem.misc4 = 0;
8473 154 tempitem.misc5 = 0;
8474 154 tempitem.misc6 = 0;
8475 154 tempitem.misc7 = 0;
8476 154 tempitem.misc8 = 0;
8477 154 tempitem.misc9 = 0;
8478 154 tempitem.misc10 = 0;
8479 154 tempitem.wpn = 0;
8480 154 tempitem.wpn2 = 0;
8481 154 tempitem.wpn3 = 0;
8482 154 tempitem.wpn4 = 0;
8483 154 tempitem.wpn5 = 0;
8484 154 tempitem.wpn6 = 0;
8485 154 tempitem.wpn7 = 0;
8486 154 tempitem.wpn8 = 0;
8487 154 tempitem.wpn9 = 0;
8488 154 tempitem.wpn10 = 0;
8489 154 break;
8490 }
8491 case itype_map: case itype_compass: case itype_bosskey:
8492 {
8493 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8494 231 tempitem.misc1 = 0;
8495 231 tempitem.misc2 = 0;
8496 231 tempitem.misc3 = 0;
8497 231 tempitem.misc4 = 0;
8498 231 tempitem.misc5 = 0;
8499 231 tempitem.misc6 = 0;
8500 231 tempitem.misc7 = 0;
8501 231 tempitem.misc8 = 0;
8502 231 tempitem.misc9 = 0;
8503 231 tempitem.misc10 = 0;
8504 231 tempitem.wpn = 0;
8505 231 tempitem.wpn2 = 0;
8506 231 tempitem.wpn3 = 0;
8507 231 tempitem.wpn4 = 0;
8508 231 tempitem.wpn5 = 0;
8509 231 tempitem.wpn6 = 0;
8510 231 tempitem.wpn7 = 0;
8511 231 tempitem.wpn8 = 0;
8512 231 tempitem.wpn9 = 0;
8513 231 tempitem.wpn10 = 0;
8514 231 break;
8515 }
8516 case itype_quiver:
8517 {
8518 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8519 308 tempitem.misc3 = 0;
8520 308 tempitem.misc4 = 0;
8521 308 tempitem.misc5 = 0;
8522 308 tempitem.misc6 = 0;
8523 308 tempitem.misc7 = 0;
8524 308 tempitem.misc8 = 0;
8525 308 tempitem.misc9 = 0;
8526 308 tempitem.misc10 = 0;
8527 308 tempitem.wpn = 0;
8528 308 tempitem.wpn2 = 0;
8529 308 tempitem.wpn3 = 0;
8530 308 tempitem.wpn4 = 0;
8531 308 tempitem.wpn5 = 0;
8532 308 tempitem.wpn6 = 0;
8533 308 tempitem.wpn7 = 0;
8534 308 tempitem.wpn8 = 0;
8535 308 tempitem.wpn9 = 0;
8536 308 tempitem.wpn10 = 0;
8537 308 break;
8538 }
8539 case itype_lkey:
8540 {
8541 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8542 77 tempitem.misc1 = 0;
8543 77 tempitem.misc2 = 0;
8544 77 tempitem.misc3 = 0;
8545 77 tempitem.misc4 = 0;
8546 77 tempitem.misc5 = 0;
8547 77 tempitem.misc6 = 0;
8548 77 tempitem.misc7 = 0;
8549 77 tempitem.misc8 = 0;
8550 77 tempitem.misc9 = 0;
8551 77 tempitem.misc10 = 0;
8552 77 tempitem.wpn = 0;
8553 77 tempitem.wpn2 = 0;
8554 77 tempitem.wpn3 = 0;
8555 77 tempitem.wpn4 = 0;
8556 77 tempitem.wpn5 = 0;
8557 77 tempitem.wpn6 = 0;
8558 77 tempitem.wpn7 = 0;
8559 77 tempitem.wpn8 = 0;
8560 77 tempitem.wpn9 = 0;
8561 77 tempitem.wpn10 = 0;
8562 77 break;
8563 }
8564 case itype_cbyrna:
8565 {
8566 77 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8567 77 tempitem.misc4 = 0;
8568 77 tempitem.misc5 = 0;
8569 77 tempitem.misc6 = 0;
8570 77 tempitem.misc7 = 0;
8571 77 tempitem.misc8 = 0;
8572 77 tempitem.misc9 = 0;
8573 77 tempitem.misc10 = 0;
8574 77 tempitem.wpn6 = 0;
8575 77 tempitem.wpn7 = 0;
8576 77 tempitem.wpn8 = 0;
8577 77 tempitem.wpn9 = 0;
8578 77 tempitem.wpn10 = 0;
8579 77 break;
8580 }
8581 case itype_rupee: case itype_arrowammo:
8582 {
8583 970 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8584 970 tempitem.misc1 = 0;
8585 970 tempitem.misc2 = 0;
8586 970 tempitem.misc3 = 0;
8587 970 tempitem.misc4 = 0;
8588 970 tempitem.misc5 = 0;
8589 970 tempitem.misc6 = 0;
8590 970 tempitem.misc7 = 0;
8591 970 tempitem.misc8 = 0;
8592 970 tempitem.misc9 = 0;
8593 970 tempitem.misc10 = 0;
8594 970 tempitem.wpn = 0;
8595 970 tempitem.wpn2 = 0;
8596 970 tempitem.wpn3 = 0;
8597 970 tempitem.wpn4 = 0;
8598 970 tempitem.wpn5 = 0;
8599 970 tempitem.wpn6 = 0;
8600 970 tempitem.wpn7 = 0;
8601 970 tempitem.wpn8 = 0;
8602 970 tempitem.wpn9 = 0;
8603 970 tempitem.wpn10 = 0;
8604 970 break;
8605 }
8606 case itype_fairy:
8607 {
8608 136 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8609 136 tempitem.misc4 = 0;
8610 136 tempitem.misc5 = 0;
8611 136 tempitem.misc6 = 0;
8612 136 tempitem.misc7 = 0;
8613 136 tempitem.misc8 = 0;
8614 136 tempitem.misc9 = 0;
8615 136 tempitem.misc10 = 0;
8616 136 tempitem.wpn = 0;
8617 136 tempitem.wpn2 = 0;
8618 136 tempitem.wpn3 = 0;
8619 136 tempitem.wpn4 = 0;
8620 136 tempitem.wpn5 = 0;
8621 136 tempitem.wpn6 = 0;
8622 136 tempitem.wpn7 = 0;
8623 136 tempitem.wpn8 = 0;
8624 136 tempitem.wpn9 = 0;
8625 136 tempitem.wpn10 = 0;
8626 136 break;
8627 }
8628 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8629 {
8630 827 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8631 827 tempitem.misc1 = 0;
8632 827 tempitem.misc2 = 0;
8633 827 tempitem.misc3 = 0;
8634 827 tempitem.misc4 = 0;
8635 827 tempitem.misc5 = 0;
8636 827 tempitem.misc6 = 0;
8637 827 tempitem.misc7 = 0;
8638 827 tempitem.misc8 = 0;
8639 827 tempitem.misc9 = 0;
8640 827 tempitem.misc10 = 0;
8641 827 tempitem.wpn = 0;
8642 827 tempitem.wpn2 = 0;
8643 827 tempitem.wpn3 = 0;
8644 827 tempitem.wpn4 = 0;
8645 827 tempitem.wpn5 = 0;
8646 827 tempitem.wpn6 = 0;
8647 827 tempitem.wpn7 = 0;
8648 827 tempitem.wpn8 = 0;
8649 827 tempitem.wpn9 = 0;
8650 827 tempitem.wpn10 = 0;
8651 827 break;
8652 }
8653 case itype_bombbag:
8654 {
8655 308 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8656 308 tempitem.misc3 = 0;
8657 308 tempitem.misc4 = 0;
8658 308 tempitem.misc5 = 0;
8659 308 tempitem.misc6 = 0;
8660 308 tempitem.misc7 = 0;
8661 308 tempitem.misc8 = 0;
8662 308 tempitem.misc9 = 0;
8663 308 tempitem.misc10 = 0;
8664 308 tempitem.wpn = 0;
8665 308 tempitem.wpn2 = 0;
8666 308 tempitem.wpn3 = 0;
8667 308 tempitem.wpn4 = 0;
8668 308 tempitem.wpn5 = 0;
8669 308 tempitem.wpn6 = 0;
8670 308 tempitem.wpn7 = 0;
8671 308 tempitem.wpn8 = 0;
8672 308 tempitem.wpn9 = 0;
8673 308 tempitem.wpn10 = 0;
8674 308 break;
8675 }
8676 case itype_rocs:
8677 {
8678 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8679 77 tempitem.misc1 = 0;
8680 77 tempitem.misc2 = 0;
8681 77 tempitem.misc3 = 0;
8682 77 tempitem.misc4 = 0;
8683 77 tempitem.misc5 = 0;
8684 77 tempitem.misc6 = 0;
8685 77 tempitem.misc7 = 0;
8686 77 tempitem.misc8 = 0;
8687 77 tempitem.misc9 = 0;
8688 77 tempitem.misc10 = 0;
8689 77 tempitem.wpn = 0;
8690 77 tempitem.wpn2 = 0;
8691 77 tempitem.wpn3 = 0;
8692 77 tempitem.wpn4 = 0;
8693 77 tempitem.wpn5 = 0;
8694 77 tempitem.wpn6 = 0;
8695 77 tempitem.wpn7 = 0;
8696 77 tempitem.wpn8 = 0;
8697 77 tempitem.wpn9 = 0;
8698 77 tempitem.wpn10 = 0;
8699 77 break;
8700 }
8701 case itype_hoverboots:
8702 {
8703 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8704 77 tempitem.misc2 = 0;
8705 77 tempitem.misc3 = 0;
8706 77 tempitem.misc4 = 0;
8707 77 tempitem.misc5 = 0;
8708 77 tempitem.misc6 = 0;
8709 77 tempitem.misc7 = 0;
8710 77 tempitem.misc8 = 0;
8711 77 tempitem.misc9 = 0;
8712 77 tempitem.misc10 = 0;
8713 77 tempitem.wpn2 = 0;
8714 77 tempitem.wpn3 = 0;
8715 77 tempitem.wpn4 = 0;
8716 77 tempitem.wpn5 = 0;
8717 77 tempitem.wpn6 = 0;
8718 77 tempitem.wpn7 = 0;
8719 77 tempitem.wpn8 = 0;
8720 77 tempitem.wpn9 = 0;
8721 77 tempitem.wpn10 = 0;
8722 77 break;
8723 }
8724 case itype_spinscroll:
8725 {
8726 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8727 77 tempitem.misc2 = 0;
8728 77 tempitem.misc3 = 0;
8729 77 tempitem.misc4 = 0;
8730 77 tempitem.misc5 = 0;
8731 77 tempitem.misc6 = 0;
8732 77 tempitem.misc7 = 0;
8733 77 tempitem.misc8 = 0;
8734 77 tempitem.misc9 = 0;
8735 77 tempitem.misc10 = 0;
8736 77 tempitem.wpn = 0;
8737 77 tempitem.wpn2 = 0;
8738 77 tempitem.wpn3 = 0;
8739 77 tempitem.wpn4 = 0;
8740 77 tempitem.wpn5 = 0;
8741 77 tempitem.wpn6 = 0;
8742 77 tempitem.wpn7 = 0;
8743 77 tempitem.wpn8 = 0;
8744 77 tempitem.wpn9 = 0;
8745 77 tempitem.wpn10 = 0;
8746 77 break;
8747 }
8748 case itype_crossscroll:
8749 {
8750 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8751 77 tempitem.misc1 = 0;
8752 77 tempitem.misc2 = 0;
8753 77 tempitem.misc3 = 0;
8754 77 tempitem.misc4 = 0;
8755 77 tempitem.misc5 = 0;
8756 77 tempitem.misc6 = 0;
8757 77 tempitem.misc7 = 0;
8758 77 tempitem.misc8 = 0;
8759 77 tempitem.misc9 = 0;
8760 77 tempitem.misc10 = 0;
8761 77 tempitem.wpn = 0;
8762 77 tempitem.wpn2 = 0;
8763 77 tempitem.wpn3 = 0;
8764 77 tempitem.wpn4 = 0;
8765 77 tempitem.wpn5 = 0;
8766 77 tempitem.wpn6 = 0;
8767 77 tempitem.wpn7 = 0;
8768 77 tempitem.wpn8 = 0;
8769 77 tempitem.wpn9 = 0;
8770 77 tempitem.wpn10 = 0;
8771 77 break;
8772 }
8773 case itype_quakescroll:
8774 {
8775 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8776 77 tempitem.misc3 = 0;
8777 77 tempitem.misc4 = 0;
8778 77 tempitem.misc5 = 0;
8779 77 tempitem.misc6 = 0;
8780 77 tempitem.misc7 = 0;
8781 77 tempitem.misc8 = 0;
8782 77 tempitem.misc9 = 0;
8783 77 tempitem.misc10 = 0;
8784 77 tempitem.wpn = 0;
8785 77 tempitem.wpn2 = 0;
8786 77 tempitem.wpn3 = 0;
8787 77 tempitem.wpn4 = 0;
8788 77 tempitem.wpn5 = 0;
8789 77 tempitem.wpn6 = 0;
8790 77 tempitem.wpn7 = 0;
8791 77 tempitem.wpn8 = 0;
8792 77 tempitem.wpn9 = 0;
8793 77 tempitem.wpn10 = 0;
8794 77 break;
8795 }
8796 case itype_whispring:
8797 {
8798 154 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8799 154 tempitem.misc2 = 0;
8800 154 tempitem.misc3 = 0;
8801 154 tempitem.misc4 = 0;
8802 154 tempitem.misc5 = 0;
8803 154 tempitem.misc6 = 0;
8804 154 tempitem.misc7 = 0;
8805 154 tempitem.misc8 = 0;
8806 154 tempitem.misc9 = 0;
8807 154 tempitem.misc10 = 0;
8808 154 tempitem.wpn = 0;
8809 154 tempitem.wpn2 = 0;
8810 154 tempitem.wpn3 = 0;
8811 154 tempitem.wpn4 = 0;
8812 154 tempitem.wpn5 = 0;
8813 154 tempitem.wpn6 = 0;
8814 154 tempitem.wpn7 = 0;
8815 154 tempitem.wpn8 = 0;
8816 154 tempitem.wpn9 = 0;
8817 154 tempitem.wpn10 = 0;
8818 154 break;
8819 }
8820 case itype_chargering:
8821 {
8822 154 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8823 154 tempitem.misc3 = 0;
8824 154 tempitem.misc4 = 0;
8825 154 tempitem.misc5 = 0;
8826 154 tempitem.misc6 = 0;
8827 154 tempitem.misc7 = 0;
8828 154 tempitem.misc8 = 0;
8829 154 tempitem.misc9 = 0;
8830 154 tempitem.misc10 = 0;
8831 154 tempitem.wpn = 0;
8832 154 tempitem.wpn2 = 0;
8833 154 tempitem.wpn3 = 0;
8834 154 tempitem.wpn4 = 0;
8835 154 tempitem.wpn5 = 0;
8836 154 tempitem.wpn6 = 0;
8837 154 tempitem.wpn7 = 0;
8838 154 tempitem.wpn8 = 0;
8839 154 tempitem.wpn9 = 0;
8840 154 tempitem.wpn10 = 0;
8841 154 break;
8842 }
8843 case itype_perilscroll:
8844 {
8845 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8846 77 tempitem.misc2 = 0;
8847 77 tempitem.misc3 = 0;
8848 77 tempitem.misc4 = 0;
8849 77 tempitem.misc5 = 0;
8850 77 tempitem.misc6 = 0;
8851 77 tempitem.misc7 = 0;
8852 77 tempitem.misc8 = 0;
8853 77 tempitem.misc9 = 0;
8854 77 tempitem.misc10 = 0;
8855 77 tempitem.wpn = 0;
8856 77 tempitem.wpn2 = 0;
8857 77 tempitem.wpn3 = 0;
8858 77 tempitem.wpn4 = 0;
8859 77 tempitem.wpn5 = 0;
8860 77 tempitem.wpn6 = 0;
8861 77 tempitem.wpn7 = 0;
8862 77 tempitem.wpn8 = 0;
8863 77 tempitem.wpn9 = 0;
8864 77 tempitem.wpn10 = 0;
8865 77 break;
8866 }
8867 case itype_wealthmedal:
8868 {
8869 231 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8870 231 tempitem.misc2 = 0;
8871 231 tempitem.misc3 = 0;
8872 231 tempitem.misc4 = 0;
8873 231 tempitem.misc5 = 0;
8874 231 tempitem.misc6 = 0;
8875 231 tempitem.misc7 = 0;
8876 231 tempitem.misc8 = 0;
8877 231 tempitem.misc9 = 0;
8878 231 tempitem.misc10 = 0;
8879 231 tempitem.wpn = 0;
8880 231 tempitem.wpn2 = 0;
8881 231 tempitem.wpn3 = 0;
8882 231 tempitem.wpn4 = 0;
8883 231 tempitem.wpn5 = 0;
8884 231 tempitem.wpn6 = 0;
8885 231 tempitem.wpn7 = 0;
8886 231 tempitem.wpn8 = 0;
8887 231 tempitem.wpn9 = 0;
8888 231 tempitem.wpn10 = 0;
8889 231 break;
8890 }
8891 case itype_heartring:
8892 {
8893 231 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8894 231 tempitem.misc3 = 0;
8895 231 tempitem.misc4 = 0;
8896 231 tempitem.misc5 = 0;
8897 231 tempitem.misc6 = 0;
8898 231 tempitem.misc7 = 0;
8899 231 tempitem.misc8 = 0;
8900 231 tempitem.misc9 = 0;
8901 231 tempitem.misc10 = 0;
8902 231 tempitem.wpn = 0;
8903 231 tempitem.wpn2 = 0;
8904 231 tempitem.wpn3 = 0;
8905 231 tempitem.wpn4 = 0;
8906 231 tempitem.wpn5 = 0;
8907 231 tempitem.wpn6 = 0;
8908 231 tempitem.wpn7 = 0;
8909 231 tempitem.wpn8 = 0;
8910 231 tempitem.wpn9 = 0;
8911 231 tempitem.wpn10 = 0;
8912 231 break;
8913 }
8914 case itype_magicring:
8915 {
8916 308 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8917 308 tempitem.misc3 = 0;
8918 308 tempitem.misc4 = 0;
8919 308 tempitem.misc5 = 0;
8920 308 tempitem.misc6 = 0;
8921 308 tempitem.misc7 = 0;
8922 308 tempitem.misc8 = 0;
8923 308 tempitem.misc9 = 0;
8924 308 tempitem.misc10 = 0;
8925 308 tempitem.wpn = 0;
8926 308 tempitem.wpn2 = 0;
8927 308 tempitem.wpn3 = 0;
8928 308 tempitem.wpn4 = 0;
8929 308 tempitem.wpn5 = 0;
8930 308 tempitem.wpn6 = 0;
8931 308 tempitem.wpn7 = 0;
8932 308 tempitem.wpn8 = 0;
8933 308 tempitem.wpn9 = 0;
8934 308 tempitem.wpn10 = 0;
8935 308 break;
8936 }
8937 case itype_spinscroll2:
8938 {
8939 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8940 77 tempitem.misc2 = 0;
8941 77 tempitem.misc3 = 0;
8942 77 tempitem.misc4 = 0;
8943 77 tempitem.misc5 = 0;
8944 77 tempitem.misc6 = 0;
8945 77 tempitem.misc7 = 0;
8946 77 tempitem.misc8 = 0;
8947 77 tempitem.misc9 = 0;
8948 77 tempitem.misc10 = 0;
8949 77 tempitem.wpn = 0;
8950 77 tempitem.wpn2 = 0;
8951 77 tempitem.wpn3 = 0;
8952 77 tempitem.wpn4 = 0;
8953 77 tempitem.wpn5 = 0;
8954 77 tempitem.wpn6 = 0;
8955 77 tempitem.wpn7 = 0;
8956 77 tempitem.wpn8 = 0;
8957 77 tempitem.wpn9 = 0;
8958 77 tempitem.wpn10 = 0;
8959 77 break;
8960 }
8961 case itype_quakescroll2:
8962 {
8963 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8964 77 tempitem.misc3 = 0;
8965 77 tempitem.misc4 = 0;
8966 77 tempitem.misc5 = 0;
8967 77 tempitem.misc6 = 0;
8968 77 tempitem.misc7 = 0;
8969 77 tempitem.misc8 = 0;
8970 77 tempitem.misc9 = 0;
8971 77 tempitem.misc10 = 0;
8972 77 tempitem.wpn = 0;
8973 77 tempitem.wpn2 = 0;
8974 77 tempitem.wpn3 = 0;
8975 77 tempitem.wpn4 = 0;
8976 77 tempitem.wpn5 = 0;
8977 77 tempitem.wpn6 = 0;
8978 77 tempitem.wpn7 = 0;
8979 77 tempitem.wpn8 = 0;
8980 77 tempitem.wpn9 = 0;
8981 77 tempitem.wpn10 = 0;
8982 77 break;
8983 }
8984 case itype_agony:
8985 {
8986 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8987 77 tempitem.misc2 = 0;
8988 77 tempitem.misc3 = 0;
8989 77 tempitem.misc4 = 0;
8990 77 tempitem.misc5 = 0;
8991 77 tempitem.misc6 = 0;
8992 77 tempitem.misc7 = 0;
8993 77 tempitem.misc8 = 0;
8994 77 tempitem.misc9 = 0;
8995 77 tempitem.misc10 = 0;
8996 77 tempitem.wpn = 0;
8997 77 tempitem.wpn2 = 0;
8998 77 tempitem.wpn3 = 0;
8999 77 tempitem.wpn4 = 0;
9000 77 tempitem.wpn5 = 0;
9001 77 tempitem.wpn6 = 0;
9002 77 tempitem.wpn7 = 0;
9003 77 tempitem.wpn8 = 0;
9004 77 tempitem.wpn9 = 0;
9005 77 tempitem.wpn10 = 0;
9006 77 break;
9007 }
9008 case itype_stompboots:
9009 {
9010 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9011 77 tempitem.misc1 = 0;
9012 77 tempitem.misc2 = 0;
9013 77 tempitem.misc3 = 0;
9014 77 tempitem.misc4 = 0;
9015 77 tempitem.misc5 = 0;
9016 77 tempitem.misc6 = 0;
9017 77 tempitem.misc7 = 0;
9018 77 tempitem.misc8 = 0;
9019 77 tempitem.misc9 = 0;
9020 77 tempitem.misc10 = 0;
9021 77 tempitem.wpn = 0;
9022 77 tempitem.wpn2 = 0;
9023 77 tempitem.wpn3 = 0;
9024 77 tempitem.wpn4 = 0;
9025 77 tempitem.wpn5 = 0;
9026 77 tempitem.wpn6 = 0;
9027 77 tempitem.wpn7 = 0;
9028 77 tempitem.wpn8 = 0;
9029 77 tempitem.wpn9 = 0;
9030 77 tempitem.wpn10 = 0;
9031 77 break;
9032 }
9033 case itype_whimsicalring:
9034 {
9035 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9036 77 tempitem.misc2 = 0;
9037 77 tempitem.misc3 = 0;
9038 77 tempitem.misc4 = 0;
9039 77 tempitem.misc5 = 0;
9040 77 tempitem.misc6 = 0;
9041 77 tempitem.misc7 = 0;
9042 77 tempitem.misc8 = 0;
9043 77 tempitem.misc9 = 0;
9044 77 tempitem.misc10 = 0;
9045 77 tempitem.wpn = 0;
9046 77 tempitem.wpn2 = 0;
9047 77 tempitem.wpn3 = 0;
9048 77 tempitem.wpn4 = 0;
9049 77 tempitem.wpn5 = 0;
9050 77 tempitem.wpn6 = 0;
9051 77 tempitem.wpn7 = 0;
9052 77 tempitem.wpn8 = 0;
9053 77 tempitem.wpn9 = 0;
9054 77 tempitem.wpn10 = 0;
9055 77 break;
9056 }
9057 case itype_perilring:
9058 {
9059 77 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9060 77 tempitem.misc2 = 0;
9061 77 tempitem.misc3 = 0;
9062 77 tempitem.misc4 = 0;
9063 77 tempitem.misc5 = 0;
9064 77 tempitem.misc6 = 0;
9065 77 tempitem.misc7 = 0;
9066 77 tempitem.misc8 = 0;
9067 77 tempitem.misc9 = 0;
9068 77 tempitem.misc10 = 0;
9069 77 tempitem.wpn = 0;
9070 77 tempitem.wpn2 = 0;
9071 77 tempitem.wpn3 = 0;
9072 77 tempitem.wpn4 = 0;
9073 77 tempitem.wpn5 = 0;
9074 77 tempitem.wpn6 = 0;
9075 77 tempitem.wpn7 = 0;
9076 77 tempitem.wpn8 = 0;
9077 77 tempitem.wpn9 = 0;
9078 77 tempitem.wpn10 = 0;
9079 77 break;
9080 }
9081 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9082 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9083 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9084 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9085 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9086 {
9087 2017 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9088 2017 tempitem.misc1 = 0;
9089 2017 tempitem.misc2 = 0;
9090 2017 tempitem.misc3 = 0;
9091 2017 tempitem.misc4 = 0;
9092 2017 tempitem.misc5 = 0;
9093 2017 tempitem.misc6 = 0;
9094 2017 tempitem.misc7 = 0;
9095 2017 tempitem.misc8 = 0;
9096 2017 tempitem.misc9 = 0;
9097 2017 tempitem.misc10 = 0;
9098 2017 tempitem.wpn = 0;
9099 2017 tempitem.wpn2 = 0;
9100 2017 tempitem.wpn3 = 0;
9101 2017 tempitem.wpn4 = 0;
9102 2017 tempitem.wpn5 = 0;
9103 2017 tempitem.wpn6 = 0;
9104 2017 tempitem.wpn7 = 0;
9105 2017 tempitem.wpn8 = 0;
9106 2017 tempitem.wpn9 = 0;
9107 2017 tempitem.wpn10 = 0;
9108 2017 break;
9109 }
9110 }
9111 19712 }
9112 //Port quest rules to items
9113
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 31)
9114 {
9115
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_bomb)
9116 {
9117
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 86 times.
92 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9118 86 else tempitem.flags &= ~ ITEM_FLAG2;
9119 92 }
9120
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_sbomb)
9121 {
9122
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 71 times.
77 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9123 71 else tempitem.flags &= ~ ITEM_FLAG2;
9124 77 }
9125
9126
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 19312 times.
19543 else if(tempitem.family == itype_brang)
9127 {
9128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
231 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9129 231 else tempitem.flags &= ~ ITEM_FLAG4;
9130 231 }
9131
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 92 times.
19312 else if(tempitem.family == itype_wand)
9132 {
9133
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9134 90 else tempitem.flags &= ~ ITEM_FLAG3;
9135 92 }
9136 19712 }
9137
9138 //Port quest rules to items
9139
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version <= 37)
9140 {
9141
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19635 times.
19712 if(tempitem.family == itype_flippers)
9142 {
9143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9144 77 else tempitem.flags &= ~ ITEM_FLAG1;
9145 77 }
9146
2/2
✓ Branch 0 taken 13161 times.
✓ Branch 1 taken 6474 times.
19635 else if(tempitem.family == itype_sword)
9147 {
9148
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9149 6405 else tempitem.flags &= ~ ITEM_FLAG5;
9150 6474 }
9151
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 13069 times.
13161 else if(tempitem.family == itype_wand)
9152 {
9153
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 89 times.
92 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9154 89 else tempitem.flags &= ~ ITEM_FLAG5;
9155 92 }
9156
4/4
✓ Branch 0 taken 12977 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 12785 times.
13069 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9157 {
9158 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9159
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 218 times.
284 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9160 218 else tempitem.flags &= ~ ITEM_FLAG3;
9161 284 }
9162 19712 }
9163
9164
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 38)
9165 {
9166
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 19327 times.
19712 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9167 {
9168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
385 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9169 385 else tempitem.flags &= ~ITEM_FLAG4;
9170
9171
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 375 times.
385 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9172 375 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9173 385 }
9174
2/2
✓ Branch 0 taken 19098 times.
✓ Branch 1 taken 229 times.
19327 else if(tempitem.family == itype_arrow)
9175 {
9176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
229 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9177 229 else tempitem.flags &= ~ITEM_FLAG4;
9178
9179
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 225 times.
229 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9180 225 else tempitem.flags |= ITEM_FLAG2;
9181 229 }
9182 19712 }
9183
9184
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 39)
9185 {
9186
6/6
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 19543 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 192 times.
✓ Branch 5 taken 19351 times.
19712 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9187 {
9188
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 12 times.
361 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9189 349 else tempitem.flags &= ~ITEM_FLAG5;
9190 361 }
9191
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 19198 times.
19351 else if(tempitem.family == itype_potion)
9192 {
9193
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 147 times.
153 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9194 {
9195 6 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9196 6 }
9197 else
9198 {
9199 147 tempitem.flags |= ITEM_FLAG3;
9200
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 62 times.
147 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9201 62 else tempitem.flags &= ~ITEM_FLAG4;
9202 }
9203 153 }
9204
2/2
✓ Branch 0 taken 19044 times.
✓ Branch 1 taken 154 times.
19198 else if(tempitem.family == itype_triforcepiece)
9205 {
9206
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 142 times.
154 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9207 {
9208 12 tempitem.flags |= ITEM_FLAG3;
9209
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9210 6 else tempitem.flags &= ~ITEM_FLAG4;
9211 12 }
9212 else
9213 {
9214 142 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9215 }
9216 154 }
9217 19712 }
9218
9219
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 40)
9220 {
9221
4/4
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 19404 times.
19712 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9222 {
9223
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 288 times.
308 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9224 288 else tempitem.flags &= ~ITEM_FLAG1;
9225 308 }
9226
8/8
✓ Branch 0 taken 19212 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 12738 times.
✓ Branch 3 taken 6474 times.
✓ Branch 4 taken 12646 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 77 times.
✓ Branch 7 taken 12569 times.
19404 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9227 {
9228
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 6754 times.
6835 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9229 6754 else tempitem.flags &= ~ITEM_FLAG8;
9230 6835 }
9231
6/6
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
✓ Branch 2 taken 13146 times.
✓ Branch 3 taken 92 times.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 13069 times.
19712 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9232 {
9233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6643 times.
6643 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9234 6643 else tempitem.flags &= ~ITEM_FLAG7;
9235 6643 }
9236
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 77 times.
13069 else if(tempitem.family == itype_cbyrna)
9237 {
9238 77 tempitem.flags |= ITEM_FLAG7;
9239 77 }
9240 19712 }
9241
9242
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 41 )
9243 {
9244
2/2
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 6474 times.
19712 if(tempitem.family == itype_sword)
9245 {
9246
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9247 6405 else tempitem.flags &= ~ITEM_FLAG9;
9248
9249
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6405 times.
6474 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9250 6405 else tempitem.flags &= ~ITEM_FLAG10;
9251 6474 }
9252 19712 }
9253
9254
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 42 )
9255 {
9256
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19620 times.
19712 if(tempitem.family == itype_wand)
9257 {
9258
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 90 times.
92 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9259 90 else tempitem.flags &= ~ITEM_FLAG3;
9260
9261 92 tempitem.flags &= ~ITEM_FLAG6;
9262 92 }
9263
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19543 times.
19620 else if(tempitem.family == itype_hammer)
9264 {
9265 77 tempitem.flags &= ~ITEM_FLAG3;
9266 77 }
9267
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 19466 times.
19543 else if(tempitem.family == itype_cbyrna)
9268 {
9269 77 tempitem.flags |= ITEM_FLAG3;
9270
9271 77 tempitem.flags &= ~ITEM_FLAG6;
9272 77 }
9273
2/2
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 6474 times.
19466 else if(tempitem.family == itype_sword)
9274 {
9275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6474 times.
6474 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9276 6474 else tempitem.flags &= ~ITEM_FLAG6;
9277 6474 }
9278 19712 }
9279
9280
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 43 )
9281 {
9282
2/2
✓ Branch 0 taken 19589 times.
✓ Branch 1 taken 123 times.
19712 if(tempitem.family == itype_whistle)
9283 {
9284
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 120 times.
123 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9285 120 else tempitem.flags &= ~ITEM_FLAG3;
9286 123 }
9287 19712 }
9288
9289
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 45 )
9290 {
9291
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_flippers)
9292 {
9293 77 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9294 77 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9295 77 }
9296 19712 }
9297
9298
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 46 )
9299 {
9300
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if(tempitem.family == itype_raft)
9301 {
9302 77 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9303 77 }
9304 19712 }
9305
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 34 ) //! set the default counter for older quests.
9306 {
9307
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 19643 times.
19712 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9308 {
9309 69 tempitem.cost_counter[0] = 1;
9310 69 }
9311 else
9312 {
9313
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 17595 times.
19643 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9314 2048 tempitem.cost_counter[0] = 4;
9315 else
9316 {
9317 17595 tempitem.cost_amount[0] = 0;
9318 17595 tempitem.cost_counter[0] = -1;
9319 }
9320 }
9321 19712 }
9322
9323
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 35 ) //new Lens of Truth flags
9324 {
9325
2/2
✓ Branch 0 taken 19635 times.
✓ Branch 1 taken 77 times.
19712 if ( tempitem.family == itype_lens )
9326 {
9327
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if ( get_bit(quest_rules,qr_RAFTLENS) )
9328 {
9329 3 tempitem.flags |= ITEM_FLAG4;
9330 3 }
9331
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 if ( get_bit(quest_rules,qr_LENSHINTS) )
9332 {
9333 39 tempitem.flags |= ITEM_FLAG1;
9334 39 }
9335
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 73 times.
77 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9336 {
9337 4 tempitem.flags |= ITEM_FLAG5;
9338 4 }
9339 77 }
9340 19712 }
9341
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9342 {
9343
2/2
✓ Branch 0 taken 157696 times.
✓ Branch 1 taken 19712 times.
177408 for ( int32_t q = 0; q < 8; q++ )
9344 {
9345 157696 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9346 157696 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9347 157696 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9348 157696 tempitem.sprite_initiald[q] = 0;
9349 157696 }
9350
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19712 times.
59136 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9351 19712 tempitem.sprite_script = 0;
9352 19712 }
9353
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9354 {
9355 19712 tempitem.pickupflag = 0;
9356 19712 }
9357
9358
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 51 )
9359 {
9360
2/2
✓ Branch 0 taken 19520 times.
✓ Branch 1 taken 192 times.
19712 if( tempitem.family == itype_candle )
9361 {
9362 192 tempitem.misc4 = 50; //Step speed
9363 192 }
9364 19712 }
9365
9366
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19712 times.
25344 if( s_version < 52 )
9367 {
9368
2/2
✓ Branch 0 taken 19481 times.
✓ Branch 1 taken 231 times.
19712 if( tempitem.family == itype_shield )
9369 231 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9370 19712 }
9371
9372
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 24942 times.
25344 if(tempitem.fam_type==0) // Always do this
9373 402 tempitem.fam_type=1;
9374
9375 25344 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9376 25344 }
9377 99 }
9378
9379 99 return 0;
9380 99 }
9381
9382 static bool did_init_def_items = false;
9383 50445 void init_def_items()
9384 {
9385
2/2
✓ Branch 0 taken 50416 times.
✓ Branch 1 taken 29 times.
50445 if(did_init_def_items) return;
9386 29 did_init_def_items = true;
9387 29 default_items[3].cost_counter[1] = crBOMBS;
9388 29 default_items[13].cost_counter[1] = crARROWS;
9389 29 default_items[14].cost_counter[1] = crARROWS;
9390 29 default_items[48].cost_counter[1] = crBOMBS;
9391 29 default_items[57].cost_counter[1] = crARROWS;
9392 50445 }
9393 50445 void reset_itembuf(itemdata *item, int32_t id)
9394 {
9395 50445 init_def_items();
9396
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 28410 times.
50445 if(id<iLast)
9397 {
9398 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9399 28410 word tile = item->tile;
9400 28410 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9401 28410 int32_t ltm = item->ltm;
9402
9403 28410 memcpy(item,&default_items[id],sizeof(itemdata));
9404 28410 item->tile = tile;
9405 28410 item->misc_flags = miscs;
9406 28410 item->csets = cset;
9407 28410 item->frames = frames;
9408 28410 item->speed = speed;
9409 28410 item->delay = delay;
9410 28410 item->ltm = ltm;
9411 28410 }
9412 50445 }
9413
9414 8192 void reset_itemname(int32_t id)
9415 {
9416 8192 sprintf(item_string[id],"zz%03d",id);
9417
9418
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 4576 times.
8192 if(id < iLast)
9419 4576 strcpy(item_string[id],old_item_string[id]);
9420 8192 }
9421
9422 99 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9423 {
9424 99 word weapons_to_read=MAXWPNS;
9425 int32_t dummy;
9426 byte padding;
9427 wpndata tempweapon;
9428 99 word s_version=0, s_cversion=0;
9429
9430
9431
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x186)
9432 {
9433 weapons_to_read=64;
9434 }
9435
9436
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x185)
9437 {
9438 weapons_to_read=32;
9439 }
9440
9441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
9442 {
9443 99 weapons_to_read=0;
9444
9445 //section version info
9446
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
9447 {
9448 return qe_invalid;
9449 }
9450
9451 99 FFCore.quest_format[vWeaponSprites] = s_version;
9452
9453 //al_trace("Weapons version %d\n", s_version);
9454
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_cversion,f,true))
9455 {
9456 return qe_invalid;
9457 }
9458
9459 //section size
9460
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
9461 {
9462 return qe_invalid;
9463 }
9464
9465 //finally... section data
9466
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&weapons_to_read,f,true))
9467 {
9468 return qe_invalid;
9469 }
9470 99 }
9471
9472
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>2)
9473 {
9474
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<weapons_to_read; i++)
9475 {
9476 char tempname[64];
9477
9478
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(!pfread(tempname, 64, f, keepdata))
9479 {
9480 return qe_invalid;
9481 }
9482
9483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(keepdata)
9484 {
9485 24576 strcpy(weapon_string[i], tempname);
9486 24576 }
9487 24576 }
9488
9489
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<4)
9490 {
9491 if(keepdata)
9492 {
9493 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9494 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9495 }
9496 }
9497
9498
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version<5)
9499 {
9500 if(keepdata)
9501 {
9502 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9503 }
9504 }
9505
9506 /*
9507 if (s_version<6)
9508 {
9509 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9510 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9511 }
9512 */
9513 96 }
9514 else
9515 {
9516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
9517
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<WPNCNT; i++)
9518 771 reset_weaponname(i);
9519 }
9520
9521
2/2
✓ Branch 0 taken 24780 times.
✓ Branch 1 taken 99 times.
24879 for(int32_t i=0; i<weapons_to_read; i++)
9522 {
9523 24780 word oldtile = 0;
9524
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 20940 times.
24780 if (s_version < 8)
9525 {
9526
1/2
✓ Branch 0 taken 20940 times.
✗ Branch 1 not taken.
20940 if (!p_igetw(&oldtile, f, true))
9527 return qe_invalid;
9528 20940 }
9529
9530
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.misc,f,true))
9531 {
9532 return qe_invalid;
9533 }
9534
9535
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.csets,f,true))
9536 {
9537 return qe_invalid;
9538 }
9539
9540
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.frames,f,true))
9541 {
9542 return qe_invalid;
9543 }
9544
9545
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.speed,f,true))
9546 {
9547 return qe_invalid;
9548 }
9549
9550
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(!p_getc(&tempweapon.type,f,true))
9551 {
9552 return qe_invalid;
9553 }
9554
9555
2/2
✓ Branch 0 taken 19148 times.
✓ Branch 1 taken 5632 times.
24780 if ( s_version >= 7 )
9556 {
9557
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempweapon.script,f,true))
9558 {
9559 return qe_invalid;
9560 }
9561
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetl(&tempweapon.tile,f,true))
9562 {
9563 return qe_invalid;
9564 }
9565 5632 }
9566
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 19148 times.
24780 if ( s_version < 7 )
9567 {
9568 19148 tempweapon.tile = oldtile;
9569 19148 }
9570
9571
1/2
✓ Branch 0 taken 24780 times.
✗ Branch 1 not taken.
24780 if(Header->zelda_version < 0x193)
9572 {
9573 if(!p_getc(&padding,f,true))
9574 {
9575 return qe_invalid;
9576 }
9577 }
9578
9579
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 204 times.
24780 if(s_version < 6)
9580 {
9581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(i==ewFIRETRAIL)
9582 {
9583 tempweapon.misc |= WF_BEHIND;
9584 }
9585 else
9586 204 tempweapon.misc &= ~WF_BEHIND;
9587 204 }
9588
9589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24780 times.
24780 if(keepdata==true)
9590 {
9591 24780 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9592 24780 }
9593 24780 }
9594
9595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
9596 {
9597
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<2)
9598 {
9599 3 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9600 3 }
9601
9602
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version<5)
9603 {
9604 3 wpnsbuf[iwQuarterHearts].tile=1;
9605 3 wpnsbuf[iwQuarterHearts].csets=1;
9606 3 }
9607
9608
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x176)
9609 {
9610 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9611 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9612 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9613 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9614 }
9615
9616
1/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version < 0x192)||
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9618 {
9619 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9620 }
9621
9622
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if((Header->zelda_version < 0x210))
9623 {
9624 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9625 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9626 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9627 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9628 }
9629 99 }
9630
9631 99 return 0;
9632 99 }
9633
9634 99 void init_guys(int32_t guyversion)
9635 {
9636
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<MAXGUYS; i++)
9637 {
9638 50688 guysbuf[i] = default_guys[0];
9639 50688 }
9640
9641
2/2
✓ Branch 0 taken 17523 times.
✓ Branch 1 taken 99 times.
17622 for(int32_t i=0; i<OLDMAXGUYS; i++)
9642 {
9643 17523 guysbuf[i] = default_guys[i];
9644
2/2
✓ Branch 0 taken 17325 times.
✓ Branch 1 taken 198 times.
17523 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9645 17523 guysbuf[i].spr_death = iwDeath;
9646 17523 guysbuf[i].spr_spawn = iwSpawn;
9647 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9648
4/4
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 16992 times.
✓ Branch 2 taken 528 times.
✓ Branch 3 taken 3 times.
17523 if(guyversion<=3 && i==ePATRABS)
9649 {
9650 3 guysbuf[i].bosspal=spDIG;
9651 3 guysbuf[i].cset=14;
9652 3 guysbuf[i].misc9=14;
9653 3 }
9654
9655
2/2
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 531 times.
17523 if(guyversion<=3)
9656 {
9657 // Rope/Ghini Flash rules
9658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9659 {
9660
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eROPE2)
9661 {
9662 3 guysbuf[i].flags2 &= ~guy_flashing;
9663 3 }
9664 531 }
9665
9666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
531 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9667 {
9668
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9669 {
9670 18 guysbuf[i].flags2 &= ~guy_flashing;
9671 18 }
9672 531 }
9673
9674
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 if(i==eGHINI2)
9675 {
9676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9677 {
9678 3 guysbuf[i].flags2 |= guy_blinking;
9679 3 }
9680
9681
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9682 {
9683 guysbuf[i].flags2 |= guy_transparent;
9684 }
9685 3 }
9686 531 }
9687
9688 // Darknut fix
9689
10/10
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17325 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 17226 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 17127 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 17028 times.
17523 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9690 {
9691
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 180 times.
495 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9692 {
9693 315 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9694 315 guysbuf[i].s_width=guysbuf[i].e_width;
9695 315 guysbuf[i].s_height=guysbuf[i].e_height;
9696 315 }
9697 180 else guysbuf[i].s_tile=860;
9698
9699
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 15 times.
495 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9700 {
9701 15 guysbuf[i].flags |= guy_bkshield;
9702 15 }
9703 495 }
9704
9705
3/4
✓ Branch 0 taken 17424 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 17523 times.
✗ Branch 3 not taken.
17523 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9706 {
9707 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9708 }
9709 17523 }
9710 99 }
9711
9712 768 void reset_weaponname(int32_t i)
9713 {
9714
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 504 times.
768 if(i<wLast)
9715 {
9716 264 strcpy(weapon_string[i],old_weapon_string[i]);
9717 264 }
9718 else
9719 504 sprintf(weapon_string[i],"zz%03d",i);
9720 768 }
9721
9722 99 void init_item_drop_sets()
9723 {
9724
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9725 {
9726 // item_drop_sets[i] = default_item_drop_sets[0];
9727 25344 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9728 25344 }
9729
9730
2/2
✓ Branch 0 taken 1287 times.
✓ Branch 1 taken 99 times.
1386 for(int32_t i=0; i<isMAX; i++)
9731 {
9732 1287 item_drop_sets[i] = default_item_drop_sets[i];
9733
9734 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9735
2/2
✓ Branch 0 taken 12870 times.
✓ Branch 1 taken 1287 times.
14157 for(int32_t j=0; j<10; ++j)
9736 {
9737 12870 int32_t it = item_drop_sets[i].item[j];
9738
9739
3/4
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 3762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 588 times.
12870 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9740
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 8520 times.
9108 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9741 {
9742 588 item_drop_sets[i].chance[j+1]=0;
9743 588 }
9744
3/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 11886 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
12282 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9745 {
9746 item_drop_sets[i].chance[j+1]=0;
9747 }
9748
9749 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9750
2/2
✓ Branch 0 taken 12862 times.
✓ Branch 1 taken 8 times.
12870 if(itemsbuf[it].family == itype_misc)
9751 {
9752 // If a non-gameplay item was selected, then item drop was aborted.
9753 // Reflect this by increasing the 'Nothing' chance accordingly.
9754 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9755 8 item_drop_sets[i].chance[j+1]=0;
9756 8 }
9757 12870 }
9758 1287 }
9759 99 }
9760
9761 99 void init_favorites()
9762 {
9763
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9764 {
9765 19800 favorite_combos[i]=-1;
9766 19800 }
9767
9768
2/2
✓ Branch 0 taken 19800 times.
✓ Branch 1 taken 99 times.
19899 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9769 {
9770 19800 favorite_comboaliases[i]=-1;
9771 19800 }
9772 99 }
9773
9774 const char *ctype_name[cMAX]=
9775 {
9776 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9777 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9778 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9779 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9780 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9781 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9782 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9783 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9784 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9785 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9786 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9787 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9788 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9789 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9790 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9791 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9792 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9793 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9794 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9795 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9796 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9797 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9798 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9799 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9800 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9801 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9802 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9803 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9804
9805 };
9806
9807 178 int32_t init_combo_classes()
9808 {
9809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9810
2/2
✓ Branch 0 taken 31684 times.
✓ Branch 1 taken 178 times.
31862 for(int32_t i=0; i<cMAX; i++)
9811 {
9812 31684 combo_class_buf[i] = default_combo_classes[i];
9813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31684 times.
31684 if ( char const* nm = zi->getComboTypeName(i) )
9814 {
9815 31684 size_t len = strlen(nm);
9816
2/2
✓ Branch 0 taken 2027776 times.
✓ Branch 1 taken 31684 times.
2059460 for ( size_t q = 0; q < 64; q++ )
9817 {
9818
2/2
✓ Branch 0 taken 469208 times.
✓ Branch 1 taken 1558568 times.
2027776 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9819 2027776 }
9820 31684 }
9821 31684 }
9822
9823 178 return 0;
9824 }
9825
9826 77 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9827 {
9828
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 assert(v_herosprites < 6);
9829 //these are here to bypass compiler warnings about unused arguments
9830 77 cv_herosprites=cv_herosprites;
9831
9832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(keepdata)
9833 {
9834 77 zinit.hero_swim_speed=67; //default
9835 77 setupherotiles(zinit.heroAnimationStyle);
9836 77 setupherodefenses();
9837 77 setupherooffsets();
9838 77 }
9839
9840
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(v_herosprites>=0)
9841 {
9842 word tile, tile2;
9843 byte flip, extend, dummy_byte;
9844
9845
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9846 {
9847
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9848 {
9849 return qe_invalid;
9850 }
9851
9852
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9853 {
9854 return qe_invalid;
9855 }
9856
9857
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9858 {
9859 return qe_invalid;
9860 }
9861
9862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9863 {
9864 296 walkspr[i][spr_tile]=(int32_t)tile;
9865 296 walkspr[i][spr_flip]=(int32_t)flip;
9866 296 walkspr[i][spr_extend]=(int32_t)extend;
9867 296 }
9868 296 }
9869
9870
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9871 {
9872
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9873 {
9874 return qe_invalid;
9875 }
9876
9877
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9878 {
9879 return qe_invalid;
9880 }
9881
9882
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9883 {
9884 return qe_invalid;
9885 }
9886
9887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9888 {
9889 296 stabspr[i][spr_tile]=(int32_t)tile;
9890 296 stabspr[i][spr_flip]=(int32_t)flip;
9891 296 stabspr[i][spr_extend]=(int32_t)extend;
9892 296 }
9893 296 }
9894
9895
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9896 {
9897
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9898 {
9899 return qe_invalid;
9900 }
9901
9902
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9903 {
9904 return qe_invalid;
9905 }
9906
9907
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9908 {
9909 return qe_invalid;
9910 }
9911
9912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9913 {
9914 296 slashspr[i][spr_tile]=(int32_t)tile;
9915 296 slashspr[i][spr_flip]=(int32_t)flip;
9916 296 slashspr[i][spr_extend]=(int32_t)extend;
9917 296 }
9918 296 }
9919
9920
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9921 {
9922
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9923 {
9924 return qe_invalid;
9925 }
9926
9927
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9928 {
9929 return qe_invalid;
9930 }
9931
9932
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9933 {
9934 return qe_invalid;
9935 }
9936
9937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9938 {
9939 296 floatspr[i][spr_tile]=(int32_t)tile;
9940 296 floatspr[i][spr_flip]=(int32_t)flip;
9941 296 floatspr[i][spr_extend]=(int32_t)extend;
9942 296 }
9943 296 }
9944
9945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>1)
9946 {
9947
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9948 {
9949
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9950 {
9951 return qe_invalid;
9952 }
9953
9954
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9955 {
9956 return qe_invalid;
9957 }
9958
9959
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9960 {
9961 return qe_invalid;
9962 }
9963
9964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9965 {
9966 296 swimspr[i][spr_tile]=(int32_t)tile;
9967 296 swimspr[i][spr_flip]=(int32_t)flip;
9968 296 swimspr[i][spr_extend]=(int32_t)extend;
9969 296 }
9970 296 }
9971 74 }
9972
9973
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9974 {
9975
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9976 {
9977 return qe_invalid;
9978 }
9979
9980
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9981 {
9982 return qe_invalid;
9983 }
9984
9985
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9986 {
9987 return qe_invalid;
9988 }
9989
9990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9991 {
9992 296 divespr[i][spr_tile]=(int32_t)tile;
9993 296 divespr[i][spr_flip]=(int32_t)flip;
9994 296 divespr[i][spr_extend]=(int32_t)extend;
9995 296 }
9996 296 }
9997
9998
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9999 {
10000
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10001 {
10002 return qe_invalid;
10003 }
10004
10005
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10006 {
10007 return qe_invalid;
10008 }
10009
10010
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10011 {
10012 return qe_invalid;
10013 }
10014
10015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10016 {
10017 296 poundspr[i][spr_tile]=(int32_t)tile;
10018 296 poundspr[i][spr_flip]=(int32_t)flip;
10019 296 poundspr[i][spr_extend]=(int32_t)extend;
10020 296 }
10021 296 }
10022
10023
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&tile,f,keepdata))
10024 {
10025 return qe_invalid;
10026 }
10027
10028 74 flip=0;
10029
10030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>0)
10031 {
10032
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&flip,f,keepdata))
10033 {
10034 return qe_invalid;
10035 }
10036 74 }
10037
10038
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&extend,f,keepdata))
10039 {
10040 return qe_invalid;
10041 }
10042
10043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10044 {
10045 74 castingspr[spr_tile]=(int32_t)tile;
10046 74 castingspr[spr_flip]=(int32_t)flip;
10047 74 castingspr[spr_extend]=(int32_t)extend;
10048 74 }
10049
10050
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(v_herosprites>0)
10051 {
10052 74 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10053
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 74 times.
222 for(int32_t i=0; i<2; i++)
10054 {
10055
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 148 times.
444 for(int32_t j=0; j<num_holdsprs; j++)
10056 {
10057
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10068 {
10069 return qe_invalid;
10070 }
10071
10072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10073 {
10074 296 holdspr[i][j][spr_tile]=(int32_t)tile;
10075 296 holdspr[i][j][spr_flip]=(int32_t)flip;
10076 296 holdspr[i][j][spr_extend]=(int32_t)extend;
10077 296 }
10078 296 }
10079 148 }
10080 74 }
10081 else
10082 {
10083 for(int32_t i=0; i<2; i++)
10084 {
10085 if(!p_igetw(&tile,f,keepdata))
10086 {
10087 return qe_invalid;
10088 }
10089
10090 if(!p_igetw(&tile2,f,keepdata))
10091 {
10092 return qe_invalid;
10093 }
10094
10095 if(!p_getc(&extend,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100 if(keepdata)
10101 {
10102 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10103 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10104 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10105 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10106 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10107 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10108 }
10109 }
10110 }
10111
10112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>2)
10113 {
10114
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10115 {
10116
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10117 {
10118 return qe_invalid;
10119 }
10120
10121
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10122 {
10123 return qe_invalid;
10124 }
10125
10126
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10127 {
10128 return qe_invalid;
10129 }
10130
10131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10132 {
10133 296 jumpspr[i][spr_tile]=(int32_t)tile;
10134 296 jumpspr[i][spr_flip]=(int32_t)flip;
10135 296 jumpspr[i][spr_extend]=(int32_t)extend;
10136 296 }
10137 296 }
10138 74 }
10139
10140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>3)
10141 {
10142
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10143 {
10144
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10145 {
10146 return qe_invalid;
10147 }
10148
10149
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10150 {
10151 return qe_invalid;
10152 }
10153
10154
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10155 {
10156 return qe_invalid;
10157 }
10158
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10160 {
10161 296 chargespr[i][spr_tile]=(int32_t)tile;
10162 296 chargespr[i][spr_flip]=(int32_t)flip;
10163 296 chargespr[i][spr_extend]=(int32_t)extend;
10164 296 }
10165 296 }
10166 74 }
10167
10168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>4)
10169 {
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(!p_getc(&dummy_byte,f,keepdata))
10171 {
10172 return qe_invalid;
10173 }
10174
10175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10176 {
10177 74 zinit.hero_swim_speed=(byte)dummy_byte;
10178 74 }
10179 74 }
10180
10181
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(keepdata)
10182 {
10183 74 memset(frozenspr, 0, sizeof(frozenspr));
10184 74 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10185 74 memset(onfirespr, 0, sizeof(onfirespr));
10186 74 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10187 74 memset(diggingspr, 0, sizeof(diggingspr));
10188 74 memset(usingrodspr, 0, sizeof(usingrodspr));
10189 74 memset(usingcanespr, 0, sizeof(usingcanespr));
10190 74 memset(pushingspr, 0, sizeof(pushingspr));
10191 74 memset(liftingspr, 0, sizeof(liftingspr));
10192 74 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10193 74 memset(stunnedspr, 0, sizeof(stunnedspr));
10194 74 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10195 74 memset(fallingspr, 0, sizeof(fallingspr));
10196 74 memset(shockedspr, 0, sizeof(shockedspr));
10197 74 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10198 74 memset(pullswordspr, 0, sizeof(pullswordspr));
10199 74 memset(readingspr, 0, sizeof(readingspr));
10200 74 memset(slash180spr, 0, sizeof(slash180spr));
10201 74 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10202 74 memset(dashspr, 0, sizeof(dashspr));
10203 74 memset(bonkspr, 0, sizeof(bonkspr));
10204 74 memset(medallionsprs, 0, sizeof(medallionsprs));
10205 74 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10206 74 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10207
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t q = 0; q < 4; ++q)
10208 {
10209
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 296 times.
1184 for(int32_t p = 0; p < 3; ++p)
10210 {
10211 888 drowningspr[q][p] = divespr[q][p];
10212 888 drowning_lavaspr[q][p] = divespr[q][p];
10213 888 }
10214 296 }
10215 74 memset(sideswimspr, 0, sizeof(sideswimspr));
10216 74 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10217 74 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10218 74 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10219 74 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10220 74 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10221 74 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10222 74 }
10223 74 }
10224
10225 77 return 0;
10226 77 }
10227
10228 3740 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10229 {
10230 3740 arr[spr_tile] = tile;
10231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_flip] = (flip > 3 ? 0 : flip);
10232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3740 times.
3740 arr[spr_extend] = (ext > 2 ? 0 : ext);
10233 3740 }
10234 //Used to read the player sprites as int32_t, not word.
10235 22 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10236 {
10237 //these are here to bypass compiler warnings about unused arguments
10238 22 cv_herosprites=cv_herosprites;
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10241 {
10242 22 zinit.hero_swim_speed=67; //default
10243 22 setupherotiles(zinit.heroAnimationStyle);
10244 22 setupherodefenses();
10245 22 setupherooffsets();
10246 22 }
10247
10248 int32_t tile, tile2;
10249 byte flip, extend, dummy_byte;
10250
10251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>=0)
10252 {
10253
10254
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10255 {
10256
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10257 {
10258 return qe_invalid;
10259 }
10260
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10262 {
10263 return qe_invalid;
10264 }
10265
10266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10267 {
10268 return qe_invalid;
10269 }
10270
10271 88 if(keepdata)
10272 {
10273 88 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10274 88 }
10275 88 }
10276
10277
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10278 {
10279
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10280 {
10281 return qe_invalid;
10282 }
10283
10284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10290 {
10291 return qe_invalid;
10292 }
10293
10294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10295 {
10296 88 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10297 88 }
10298 88 }
10299
10300
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10301 {
10302
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10303 {
10304 return qe_invalid;
10305 }
10306
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10308 {
10309 return qe_invalid;
10310 }
10311
10312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10313 {
10314 return qe_invalid;
10315 }
10316
10317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10318 {
10319 88 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10320 88 }
10321 88 }
10322
10323
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10324 {
10325
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10326 {
10327 return qe_invalid;
10328 }
10329
10330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10331 {
10332 return qe_invalid;
10333 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10336 {
10337 return qe_invalid;
10338 }
10339
10340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10341 {
10342 88 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10343 88 }
10344 88 }
10345
10346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>1)
10347 {
10348
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10349 {
10350
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10351 {
10352 return qe_invalid;
10353 }
10354
10355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10356 {
10357 return qe_invalid;
10358 }
10359
10360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10361 {
10362 return qe_invalid;
10363 }
10364
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10366 {
10367 88 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10368 88 }
10369 88 }
10370 22 }
10371
10372
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10373 {
10374
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10375 {
10376 return qe_invalid;
10377 }
10378
10379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10380 {
10381 return qe_invalid;
10382 }
10383
10384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10385 {
10386 return qe_invalid;
10387 }
10388
10389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10390 {
10391 88 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10392 88 }
10393 88 }
10394
10395
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10396 {
10397
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10398 {
10399 return qe_invalid;
10400 }
10401
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10403 {
10404 return qe_invalid;
10405 }
10406
10407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10408 {
10409 return qe_invalid;
10410 }
10411
10412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10413 {
10414 88 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10415 88 }
10416 88 }
10417
10418
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
10419 {
10420 return qe_invalid;
10421 }
10422
10423 22 flip=0;
10424
10425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>0)
10426 {
10427
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
10428 {
10429 return qe_invalid;
10430 }
10431 22 }
10432
10433
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
10434 {
10435 return qe_invalid;
10436 }
10437
10438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10439 {
10440 22 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10441 22 }
10442
10443
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>0)
10444 {
10445 22 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10446
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
66 for(int32_t i=0; i<2; i++)
10447 {
10448
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 44 times.
176 for(int32_t j=0; j<num_holdsprs; j++)
10449 {
10450
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tile,f,keepdata))
10451 {
10452 return qe_invalid;
10453 }
10454
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&flip,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(!p_getc(&extend,f,keepdata))
10461 {
10462 return qe_invalid;
10463 }
10464
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(keepdata)
10466 {
10467 132 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10468 132 }
10469 132 }
10470 44 }
10471 22 }
10472 else
10473 {
10474 for(int32_t i=0; i<2; i++)
10475 {
10476 if(!p_igetl(&tile,f,keepdata))
10477 {
10478 return qe_invalid;
10479 }
10480
10481 if(!p_igetl(&tile2,f,keepdata))
10482 {
10483 return qe_invalid;
10484 }
10485
10486 if(!p_getc(&extend,f,keepdata))
10487 {
10488 return qe_invalid;
10489 }
10490
10491 if(keepdata)
10492 {
10493 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10494 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10495 }
10496 }
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>2)
10500 {
10501
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10502 {
10503
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10504 {
10505 return qe_invalid;
10506 }
10507
10508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10514 {
10515 return qe_invalid;
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10519 {
10520 88 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10521 88 }
10522 88 }
10523 22 }
10524
10525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>3)
10526 {
10527
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t i=0; i<4; i++)
10528 {
10529
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10530 {
10531 return qe_invalid;
10532 }
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10535 {
10536 return qe_invalid;
10537 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10540 {
10541 return qe_invalid;
10542 }
10543
10544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10545 {
10546 88 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10547 88 }
10548 88 }
10549 22 }
10550
10551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(v_herosprites>4)
10552 {
10553
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&dummy_byte,f,keepdata))
10554 {
10555 return qe_invalid;
10556 }
10557
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(keepdata)
10559 {
10560 22 zinit.hero_swim_speed=(byte)dummy_byte;
10561 22 }
10562 22 }
10563
10564
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(v_herosprites>6)
10565 {
10566
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10567 {
10568
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10569 return qe_invalid;
10570
10571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10572 return qe_invalid;
10573
10574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10575 return qe_invalid;
10576
10577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10578 {
10579 88 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10580 88 }
10581 88 }
10582
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10583 {
10584
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10585 return qe_invalid;
10586
10587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10588 return qe_invalid;
10589
10590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10591 return qe_invalid;
10592
10593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10594 {
10595 88 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10596 88 }
10597 88 }
10598
10599
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10600 {
10601
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10602 return qe_invalid;
10603
10604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10605 return qe_invalid;
10606
10607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10608 return qe_invalid;
10609
10610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10611 {
10612 88 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10613 88 }
10614 88 }
10615
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10616 {
10617
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10618 return qe_invalid;
10619
10620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10621 return qe_invalid;
10622
10623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10624 return qe_invalid;
10625
10626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10627 {
10628 88 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10629 88 }
10630 88 }
10631
10632
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10633 {
10634
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10635 return qe_invalid;
10636
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10638 return qe_invalid;
10639
10640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10641 return qe_invalid;
10642
10643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10644 {
10645 88 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10646 88 }
10647 88 }
10648
10649
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10650 {
10651
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10652 return qe_invalid;
10653
10654
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10658 return qe_invalid;
10659
10660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10661 {
10662 88 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10663 88 }
10664 88 }
10665
10666
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10667 {
10668
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10669 return qe_invalid;
10670
10671
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10672 return qe_invalid;
10673
10674
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10675 return qe_invalid;
10676
10677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10678 {
10679 88 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10680 88 }
10681 88 }
10682
10683
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10684 {
10685
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10686 return qe_invalid;
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10689 return qe_invalid;
10690
10691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10692 return qe_invalid;
10693
10694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10695 {
10696 88 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10697 88 }
10698 88 }
10699
10700
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10701 {
10702
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10703 return qe_invalid;
10704
10705
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10706 return qe_invalid;
10707
10708
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10709 return qe_invalid;
10710
10711 88 byte frames = 0;
10712
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 80 times.
88 if(v_herosprites > 15)
10713 {
10714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!p_getc(&frames,f,keepdata))
10715 return qe_invalid;
10716 80 }
10717
10718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10719 {
10720 88 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10721 88 liftingspr[q][spr_frames] = frames;
10722 88 }
10723 88 }
10724
10725
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10726 {
10727
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10728 return qe_invalid;
10729
10730
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10731 return qe_invalid;
10732
10733
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10734 return qe_invalid;
10735
10736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10737 {
10738 88 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10739 88 }
10740 88 }
10741
10742
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10743 {
10744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10745 return qe_invalid;
10746
10747
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10748 return qe_invalid;
10749
10750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10751 return qe_invalid;
10752
10753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10754 {
10755 88 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10756 88 }
10757 88 }
10758
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10759 {
10760
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10761 return qe_invalid;
10762
10763
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10764 return qe_invalid;
10765
10766
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10767 return qe_invalid;
10768
10769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10770 {
10771 88 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10772 88 }
10773 88 }
10774
10775
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10776 {
10777
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10778 return qe_invalid;
10779
10780
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10781 return qe_invalid;
10782
10783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10784 return qe_invalid;
10785
10786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10787 {
10788 88 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10789 88 }
10790 88 }
10791
10792
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10793 {
10794
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10795 return qe_invalid;
10796
10797
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10798 return qe_invalid;
10799
10800
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10801 return qe_invalid;
10802
10803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10804 {
10805 88 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10806 88 }
10807 88 }
10808
10809
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10810 {
10811
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10812 return qe_invalid;
10813
10814
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10815 return qe_invalid;
10816
10817
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10818 return qe_invalid;
10819
10820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10821 {
10822 88 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10823 88 }
10824 88 }
10825
10826
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10827 {
10828
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10829 return qe_invalid;
10830
10831
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10832 return qe_invalid;
10833
10834
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10835 return qe_invalid;
10836
10837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10838 {
10839 88 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10840 88 }
10841 88 }
10842
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10843 {
10844
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10845 return qe_invalid;
10846
10847
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10848 return qe_invalid;
10849
10850
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10851 return qe_invalid;
10852
10853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10854 {
10855 88 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 88 }
10857 88 }
10858
10859
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10860 {
10861
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10862 return qe_invalid;
10863
10864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
10865 return qe_invalid;
10866
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10868 return qe_invalid;
10869
10870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10871 {
10872 88 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10873 88 }
10874 88 }
10875
10876
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10877 {
10878
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10879 return qe_invalid;
10880
10881
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10882 return qe_invalid;
10883
10884
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10885 return qe_invalid;
10886
10887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10888 {
10889 88 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10890 88 }
10891 88 }
10892
10893
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10894 {
10895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&tile,f,keepdata))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10899 return qe_invalid;
10900
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10905 {
10906 88 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10907 88 }
10908 88 }
10909
10910
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10911 {
10912
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10919 return qe_invalid;
10920
10921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10922 {
10923 88 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10924 88 }
10925 88 }
10926
10927
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10928 {
10929
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10933 return qe_invalid;
10934
10935
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10936 return qe_invalid;
10937
10938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10939 {
10940 88 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10941 88 }
10942 88 }
10943
10944
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
10945 {
10946
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&flip,f,keepdata))
10950 return qe_invalid;
10951
10952
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_getc(&extend,f,keepdata))
10953 return qe_invalid;
10954
10955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
10956 {
10957 88 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10958 88 }
10959 88 }
10960
10961
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10962 {
10963
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
10964 return qe_invalid;
10965
10966
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&flip,f,keepdata))
10967 return qe_invalid;
10968
10969
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_getc(&extend,f,keepdata))
10970 return qe_invalid;
10971
10972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
10973 {
10974 66 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10975 66 }
10976 66 }
10977 22 }
10978 else if(keepdata)
10979 {
10980 memset(frozenspr, 0, sizeof(frozenspr));
10981 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10982 memset(onfirespr, 0, sizeof(onfirespr));
10983 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10984 memset(diggingspr, 0, sizeof(diggingspr));
10985 memset(usingrodspr, 0, sizeof(usingrodspr));
10986 memset(usingcanespr, 0, sizeof(usingcanespr));
10987 memset(pushingspr, 0, sizeof(pushingspr));
10988 memset(liftingspr, 0, sizeof(liftingspr));
10989 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10990 memset(stunnedspr, 0, sizeof(stunnedspr));
10991 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10992 memset(fallingspr, 0, sizeof(fallingspr));
10993 memset(shockedspr, 0, sizeof(shockedspr));
10994 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10995 memset(pullswordspr, 0, sizeof(pullswordspr));
10996 memset(readingspr, 0, sizeof(readingspr));
10997 memset(slash180spr, 0, sizeof(slash180spr));
10998 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10999 memset(dashspr, 0, sizeof(dashspr));
11000 memset(bonkspr, 0, sizeof(bonkspr));
11001 memset(medallionsprs, 0, sizeof(medallionsprs));
11002 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11003 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11004 for(int32_t q = 0; q < 4; ++q)
11005 {
11006 for(int32_t p = 0; p < 3; ++p)
11007 {
11008 drowningspr[q][p] = divespr[q][p];
11009 drowning_lavaspr[q][p] = divespr[q][p];
11010 }
11011 }
11012 }
11013
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 8)
11014 {
11015
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11016 {
11017
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11018 return qe_invalid;
11019
11020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11021 return qe_invalid;
11022
11023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11024 return qe_invalid;
11025
11026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11027 {
11028 88 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11029 88 }
11030 88 }
11031 22 }
11032 else if (keepdata)
11033 {
11034 memset(sideswimspr, 0, sizeof(sideswimspr));
11035 }
11036
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 9)
11037 {
11038
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11039 {
11040
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11041 return qe_invalid;
11042
11043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11044 return qe_invalid;
11045
11046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11047 return qe_invalid;
11048
11049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11050 {
11051 88 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11052 88 }
11053 88 }
11054
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11055 {
11056
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11057 return qe_invalid;
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11060 return qe_invalid;
11061
11062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11063 return qe_invalid;
11064
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11066 {
11067 88 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11068 88 }
11069 88 }
11070
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11071 {
11072
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11073 return qe_invalid;
11074
11075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11076 return qe_invalid;
11077
11078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11079 return qe_invalid;
11080
11081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11082 {
11083 88 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11084 88 }
11085 88 }
11086
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11087 {
11088
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11089 return qe_invalid;
11090
11091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11092 return qe_invalid;
11093
11094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11095 return qe_invalid;
11096
11097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11098 {
11099 88 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11100 88 }
11101 88 }
11102 22 }
11103 else if (keepdata)
11104 {
11105 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11106 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11107 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11108 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11109 }
11110
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 10)
11111 {
11112
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11113 {
11114 int32_t hmr;
11115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_igetl(&hmr,f,keepdata))
11116 return qe_invalid;
11117
11118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11119 {
11120 88 hammeroffsets[q] = hmr;
11121 88 }
11122 88 }
11123 22 }
11124 else if (keepdata)
11125 {
11126 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11127 }
11128
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 11)
11129 {
11130
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 for(int32_t q = 0; q < 3; ++q)
11131 {
11132
1/2
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
66 if(!p_igetl(&tile,f,keepdata))
11133 return qe_invalid;
11134
11135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&flip,f,keepdata))
11136 return qe_invalid;
11137
11138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(!p_getc(&extend,f,keepdata))
11139 return qe_invalid;
11140
11141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(keepdata)
11142 {
11143 66 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11144 66 }
11145 66 }
11146 22 }
11147 else if (keepdata)
11148 {
11149 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11150 }
11151
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 12)
11152 {
11153
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tile,f,keepdata))
11154 return qe_invalid;
11155
11156
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&flip,f,keepdata))
11157 return qe_invalid;
11158
11159
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&extend,f,keepdata))
11160 return qe_invalid;
11161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (keepdata)
11162 {
11163 22 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11164 22 }
11165
11166 22 }
11167 else if (keepdata)
11168 {
11169 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11170 }
11171
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 13)
11172 {
11173
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11174 {
11175
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11176 return qe_invalid;
11177
11178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11179 return qe_invalid;
11180
11181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11182 return qe_invalid;
11183
11184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11185 {
11186 88 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11187 88 }
11188 88 }
11189 22 }
11190 else if (keepdata)
11191 {
11192 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11193 }
11194
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 14)
11195 {
11196
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 22 times.
110 for(int32_t q = 0; q < 4; ++q)
11197 {
11198
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&tile,f,keepdata))
11199 return qe_invalid;
11200
11201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&flip,f,keepdata))
11202 return qe_invalid;
11203
11204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(!p_getc(&extend,f,keepdata))
11205 return qe_invalid;
11206
11207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
11208 {
11209 88 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11210 88 }
11211 88 }
11212 22 }
11213 else if (keepdata)
11214 {
11215 memset(revslashspr, 0, sizeof(revslashspr));
11216 }
11217
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (v_herosprites > 7)
11218 {
11219 22 int32_t num_defense = wMax;
11220 22 byte def = 0;
11221
11222 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11223 /*if(v_herosprites > [x])
11224 * {
11225 * num_defense = 146 //value of wMax on version 8
11226 * }
11227 */
11228
11229
2/2
✓ Branch 0 taken 3212 times.
✓ Branch 1 taken 22 times.
3234 for (int32_t q = 0; q < num_defense; q++)
11230 {
11231
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if (!p_getc(&def, f, keepdata))
11232 return qe_invalid;
11233
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3212 times.
3212 if (keepdata)
11235 {
11236 3212 hero_defence[q] = def;
11237 3212 }
11238 3212 }
11239 22 }
11240 else if (keepdata)
11241 {
11242 int32_t num_defense = wMax;
11243 for (int32_t q = 0; q < num_defense; q++)
11244 {
11245 hero_defence[q] = 0;
11246 }
11247 }
11248 22 }
11249
11250 22 return 0;
11251 22 }
11252
11253
11254 96 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11255 {
11256 //these are here to bypass compiler warnings about unused arguments
11257 96 Header=Header;
11258
11259 dword dummy;
11260 96 word s_version=0, s_cversion=0;
11261
11262 //section version info
11263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11264 {
11265 return qe_invalid;
11266 }
11267
11268 96 FFCore.quest_format[vHeroSprites] = s_version;
11269
11270 //al_trace("Player sprites version %d\n", s_version);
11271
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11272 {
11273 return qe_invalid;
11274 }
11275
11276 //section size
11277
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11278 {
11279 return qe_invalid;
11280 }
11281
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( s_version >= 6 )
11282 {
11283 //al_trace("Reading Player Sprites v6\n");
11284 22 return readherosprites3(f, s_version, dummy, keepdata);
11285 }
11286 74 else return readherosprites2(f, s_version, dummy, keepdata);
11287 96 }
11288
11289 96 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11290 {
11291 int32_t dummy;
11292 96 word s_version=0, s_cversion=0;
11293
11294 //section version info
11295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
11296 {
11297 return qe_invalid;
11298 }
11299
11300 96 FFCore.quest_format[vSubscreen] = s_version;
11301
11302 //al_trace("Subscreens version %d\n", s_version);
11303
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
11304 {
11305 return qe_invalid;
11306 }
11307
11308 //section size
11309
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
11310 {
11311 return qe_invalid;
11312 }
11313
11314 //finally... section data
11315
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 96 times.
12384 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11316 {
11317 12288 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11318
11319
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(ret!=0) return ret;
11320 12288 }
11321
11322 96 return 0;
11323 96 }
11324
11325 12288 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11326 {
11327 12288 int32_t numsub=0;
11328 12288 byte temp_ss=0;
11329 subscreen_object temp_sub_stack;
11330 12288 subscreen_object *temp_sub = &temp_sub_stack;
11331
11332 char tempname[64];
11333
11334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(!pfread(tempname,64,f,true))
11335 {
11336 return qe_invalid;
11337 }
11338
11339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version > 1)
11340 {
11341
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_getc(&temp_ss,f,keepdata))
11342 {
11343 return qe_invalid;
11344 }
11345 12288 }
11346
11347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12288 times.
12288 if(s_version < 4)
11348 {
11349 uint8_t tmp=0;
11350
11351 if(!p_getc(&tmp,f,true))
11352 {
11353 return qe_invalid;
11354 }
11355
11356 numsub = (int32_t)tmp;
11357 }
11358 else
11359 {
11360 word tmp;
11361
11362
1/2
✓ Branch 0 taken 12288 times.
✗ Branch 1 not taken.
12288 if(!p_igetw(&tmp, f, true))
11363 {
11364 return qe_invalid;
11365 }
11366
11367 12288 numsub = (int32_t)tmp;
11368 }
11369
11370 int32_t j;
11371
11372
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32006 times.
✓ Branch 2 taken 19718 times.
✓ Branch 3 taken 12288 times.
32006 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11373 {
11374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11375 {
11376 19718 memset(temp_sub,0,sizeof(subscreen_object));
11377
11378
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 18571 times.
19718 switch(custom_subscreen[i].objects[j].type)
11379 {
11380 case ssoTEXT:
11381 case ssoTEXTBOX:
11382 case ssoCURRENTITEMTEXT:
11383 case ssoCURRENTITEMCLASSTEXT:
11384
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1147 times.
✓ Branch 2 taken 1147 times.
✗ Branch 3 not taken.
1147 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11385
11386 //fall through
11387 default:
11388 19718 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11389 19718 break;
11390 }
11391 19718 }
11392
11393
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->type),f,true))
11394 {
11395 return qe_invalid;
11396 }
11397
11398
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->pos),f,keepdata))
11399 {
11400 return qe_invalid;
11401 }
11402
11403
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(s_version < 5)
11404 {
11405 switch(temp_sub->pos)
11406 {
11407 case 0:
11408 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11409 break;
11410
11411 case 1:
11412 temp_sub->pos = sspUP;
11413 break;
11414
11415 case 2:
11416 temp_sub->pos = sspDOWN;
11417 break;
11418
11419 default:
11420 temp_sub->pos = 0;
11421 }
11422 }
11423
11424
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->x),f,keepdata))
11425 {
11426 return qe_invalid;
11427 }
11428
11429
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->y),f,keepdata))
11430 {
11431 return qe_invalid;
11432 }
11433
11434
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->w),f,keepdata))
11435 {
11436 return qe_invalid;
11437 }
11438
11439
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->h),f,keepdata))
11440 {
11441 return qe_invalid;
11442 }
11443
11444
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11445 {
11446 return qe_invalid;
11447 }
11448
11449
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11450 {
11451 return qe_invalid;
11452 }
11453
11454
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11455 {
11456 return qe_invalid;
11457 }
11458
11459
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11460 {
11461 return qe_invalid;
11462 }
11463
11464
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11465 {
11466 return qe_invalid;
11467 }
11468
11469
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11470 {
11471 return qe_invalid;
11472 }
11473
11474
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11475 {
11476 return qe_invalid;
11477 }
11478
11479
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11480 {
11481 return qe_invalid;
11482 }
11483
11484
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11485 {
11486 return qe_invalid;
11487 }
11488
11489
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11490 {
11491 return qe_invalid;
11492 }
11493
11494
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11495 {
11496 return qe_invalid;
11497 }
11498
11499
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11500 {
11501 return qe_invalid;
11502 }
11503
11504
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11505 {
11506 return qe_invalid;
11507 }
11508
11509
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11510 {
11511 return qe_invalid;
11512 }
11513
11514
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11515 {
11516 return qe_invalid;
11517 }
11518
11519
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11520 {
11521 return qe_invalid;
11522 }
11523
11524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(s_version < 2)
11525 {
11526 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11527 {
11528 return qe_invalid;
11529 }
11530
11531 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11532 {
11533 return qe_invalid;
11534 }
11535
11536 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11537 {
11538 return qe_invalid;
11539 }
11540 }
11541 else
11542 {
11543
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->speed),f,keepdata))
11544 {
11545 return qe_invalid;
11546 }
11547
11548
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_getc(&(temp_sub->delay),f,keepdata))
11549 {
11550 return qe_invalid;
11551 }
11552
11553
1/2
✓ Branch 0 taken 19718 times.
✗ Branch 1 not taken.
19718 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11554 {
11555 return qe_invalid;
11556 }
11557 }
11558
11559 19718 int32_t temp_size=0;
11560
11561 // bool deletets = false;
11562
4/4
✓ Branch 0 taken 8380 times.
✓ Branch 1 taken 1605 times.
✓ Branch 2 taken 9590 times.
✓ Branch 3 taken 143 times.
19718 switch(temp_sub->type)
11563 {
11564 case ssoTEXT:
11565 case ssoTEXTBOX:
11566 case ssoCURRENTITEMTEXT:
11567 case ssoCURRENTITEMCLASSTEXT:
11568 word temptempsize;
11569 /*uint8_t temp1;
11570 uint8_t temp2;
11571 temp2 = 0;
11572 if(!p_getc(&temp1,f,true))
11573 {
11574 return qe_invalid;
11575 }
11576 if(temp1)
11577 {
11578
11579 if(!p_getc(&temp2,f,true))
11580 {
11581 return qe_invalid;
11582 }
11583 }*/
11584
11585
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!p_igetw(&temptempsize,f,true))
11586 {
11587 return qe_invalid;
11588 }
11589
11590 //temptempsize = temp1 + (temp2 << 8);
11591 1605 temp_size = (int32_t)temptempsize;
11592
11593 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(keepdata)
11595 {
11596 1605 uint32_t char_length = temp_size+1;
11597 1605 temp_sub->dp1 = new char[char_length]; //memory not freed
11598
11599 //deletets = true; //obsolete
11600 1605 }
11601
11602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if(temp_size)
11603 {
11604
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11605 {
11606 return qe_invalid;
11607 }
11608 1605 }
11609
11610 1605 break;
11611
11612 case ssoLIFEMETER:
11613
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11614 temp_sub->d3 = 1;
11615
11616
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11617 {
11618 return qe_invalid;
11619 }
11620
11621 143 break;
11622
11623
11624 case ssoCURRENTITEM:
11625
11626
1/2
✓ Branch 0 taken 8380 times.
✗ Branch 1 not taken.
8380 if(s_version < 6)
11627 {
11628 switch(temp_sub->d1)
11629 {
11630 case ssiBOMB:
11631 temp_sub->d1 = itype_bomb;
11632 break;
11633
11634 case ssiSWORD:
11635 temp_sub->d1 = itype_sword;
11636 break;
11637
11638 case ssiSHIELD:
11639 temp_sub->d1 = itype_shield;
11640 break;
11641
11642 case ssiCANDLE:
11643 temp_sub->d1 = itype_candle;
11644 break;
11645
11646 case ssiLETTER:
11647 temp_sub->d1 = itype_letter;
11648 break;
11649
11650 case ssiPOTION:
11651 temp_sub->d1 = itype_potion;
11652 break;
11653
11654 case ssiLETTERPOTION:
11655 temp_sub->d1 = itype_letterpotion;
11656 break;
11657
11658 case ssiBOW:
11659 temp_sub->d1 = itype_bow;
11660 break;
11661
11662 case ssiARROW:
11663 temp_sub->d1 = itype_arrow;
11664 break;
11665
11666 case ssiBOWANDARROW:
11667 temp_sub->d1 = itype_bowandarrow;
11668 break;
11669
11670 case ssiBAIT:
11671 temp_sub->d1 = itype_bait;
11672 break;
11673
11674 case ssiRING:
11675 temp_sub->d1 = itype_ring;
11676 break;
11677
11678 case ssiBRACELET:
11679 temp_sub->d1 = itype_bracelet;
11680 break;
11681
11682 case ssiMAP:
11683 temp_sub->d1 = itype_map;
11684 break;
11685
11686 case ssiCOMPASS:
11687 temp_sub->d1 = itype_compass;
11688 break;
11689
11690 case ssiBOSSKEY:
11691 temp_sub->d1 = itype_bosskey;
11692 break;
11693
11694 case ssiMAGICKEY:
11695 temp_sub->d1 = itype_magickey;
11696 break;
11697
11698 case ssiBRANG:
11699 temp_sub->d1 = itype_brang;
11700 break;
11701
11702 case ssiWAND:
11703 temp_sub->d1 = itype_wand;
11704 break;
11705
11706 case ssiRAFT:
11707 temp_sub->d1 = itype_raft;
11708 break;
11709
11710 case ssiLADDER:
11711 temp_sub->d1 = itype_ladder;
11712 break;
11713
11714 case ssiWHISTLE:
11715 temp_sub->d1 = itype_whistle;
11716 break;
11717
11718 case ssiBOOK:
11719 temp_sub->d1 = itype_book;
11720 break;
11721
11722 case ssiWALLET:
11723 temp_sub->d1 = itype_wallet;
11724 break;
11725
11726 case ssiSBOMB:
11727 temp_sub->d1 = itype_sbomb;
11728 break;
11729
11730 case ssiHCPIECE:
11731 temp_sub->d1 = itype_heartpiece;
11732 break;
11733
11734 case ssiAMULET:
11735 temp_sub->d1 = itype_amulet;
11736 break;
11737
11738 case ssiFLIPPERS:
11739 temp_sub->d1 = itype_flippers;
11740 break;
11741
11742 case ssiHOOKSHOT:
11743 temp_sub->d1 = itype_hookshot;
11744 break;
11745
11746 case ssiLENS:
11747 temp_sub->d1 = itype_lens;
11748 break;
11749
11750 case ssiHAMMER:
11751 temp_sub->d1 = itype_hammer;
11752 break;
11753
11754 case ssiBOOTS:
11755 temp_sub->d1 = itype_boots;
11756 break;
11757
11758 case ssiDINSFIRE:
11759 temp_sub->d1 = itype_dinsfire;
11760 break;
11761
11762 case ssiFARORESWIND:
11763 temp_sub->d1 = itype_faroreswind;
11764 break;
11765
11766 case ssiNAYRUSLOVE:
11767 temp_sub->d1 = itype_nayruslove;
11768 break;
11769
11770 case ssiQUIVER:
11771 temp_sub->d1 = itype_quiver;
11772 break;
11773
11774 case ssiBOMBBAG:
11775 temp_sub->d1 = itype_bombbag;
11776 break;
11777
11778 case ssiCBYRNA:
11779 temp_sub->d1 = itype_cbyrna;
11780 break;
11781
11782 case ssiROCS:
11783 temp_sub->d1 = itype_rocs;
11784 break;
11785
11786 case ssiHOVERBOOTS:
11787 temp_sub->d1 = itype_hoverboots;
11788 break;
11789
11790 case ssiSPINSCROLL:
11791 temp_sub->d1 = itype_spinscroll;
11792 break;
11793
11794 case ssiCROSSSCROLL:
11795 temp_sub->d1 = itype_crossscroll;
11796 break;
11797
11798 case ssiQUAKESCROLL:
11799 temp_sub->d1 = itype_quakescroll;
11800 break;
11801
11802 case ssiWHISPRING:
11803 temp_sub->d1 = itype_whispring;
11804 break;
11805
11806 case ssiCHARGERING:
11807 temp_sub->d1 = itype_chargering;
11808 break;
11809
11810 case ssiPERILSCROLL:
11811 temp_sub->d1 = itype_perilscroll;
11812 break;
11813
11814 case ssiWEALTHMEDAL:
11815 temp_sub->d1 = itype_wealthmedal;
11816 break;
11817
11818 case ssiHEARTRING:
11819 temp_sub->d1 = itype_heartring;
11820 break;
11821
11822 case ssiMAGICRING:
11823 temp_sub->d1 = itype_magicring;
11824 break;
11825
11826 case ssiSPINSCROLL2:
11827 temp_sub->d1 = itype_spinscroll2;
11828 break;
11829
11830 case ssiQUAKESCROLL2:
11831 temp_sub->d1 = itype_quakescroll2;
11832 break;
11833
11834 case ssiAGONY:
11835 temp_sub->d1 = itype_agony;
11836 break;
11837
11838 case ssiSTOMPBOOTS:
11839 temp_sub->d1 = itype_stompboots;
11840 break;
11841
11842 case ssiWHIMSICALRING:
11843 temp_sub->d1 = itype_whimsicalring;
11844 break;
11845
11846 case ssiPERILRING:
11847 temp_sub->d1 = itype_perilring;
11848 break;
11849
11850 default:
11851 temp_sub->d1 += itype_custom1 - ssiMAX;
11852 }
11853 }
11854
11855 //fall-through
11856 default:
11857
1/2
✓ Branch 0 taken 17970 times.
✗ Branch 1 not taken.
17970 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11858 {
11859 return qe_invalid;
11860 }
11861
11862 17970 break;
11863 }
11864
11865
2/2
✓ Branch 0 taken 11341 times.
✓ Branch 1 taken 8377 times.
19718 if(s_version < 7)
11866 {
11867
3/3
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 336 times.
8377 switch(temp_sub->type)
11868 {
11869 case ssoMAGICGAUGE:
11870 {
11871
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 192 times.
204 if(!temp_sub->d9)
11872 192 temp_sub->d9 = -1; //-1 now represents 'always'
11873 204 break;
11874 }
11875 case ssoLIFEGAUGE:
11876 336 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11877 336 break;
11878 }
11879 8377 }
11880
11881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19718 times.
19718 if(keepdata)
11882 {
11883
3/3
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 17267 times.
✓ Branch 2 taken 846 times.
19718 switch(temp_sub->type)
11884 {
11885 case ssoTEXT:
11886 case ssoTEXTBOX:
11887 case ssoCURRENTITEMTEXT:
11888 case ssoCURRENTITEMCLASSTEXT:
11889
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11890
11891 1605 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11892 1605 custom_subscreen[i].objects[j].dp1 = NULL;
11893 1605 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11894 1605 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11895 1605 break;
11896
11897 case ssoCOUNTER:
11898
1/2
✓ Branch 0 taken 846 times.
✗ Branch 1 not taken.
846 if(s_version<3)
11899 {
11900 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11901 temp_sub->d8=0;
11902 }
11903
11904 default:
11905 18113 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11906 18113 break;
11907 }
11908
11909 19718 strcpy(custom_subscreen[i].name, tempname);
11910 19718 custom_subscreen[i].ss_type = temp_ss;
11911 19718 }
11912 19718 }
11913
11914
2/2
✓ Branch 0 taken 3126010 times.
✓ Branch 1 taken 12288 times.
3138298 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11915 {
11916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 if(keepdata)
11917 {
11918 //clear all unused object in this subscreen -DD
11919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126010 times.
3126010 switch(custom_subscreen[i].objects[j].type)
11920 {
11921 case ssoTEXT:
11922 case ssoTEXTBOX:
11923 case ssoCURRENTITEMTEXT:
11924 case ssoCURRENTITEMCLASSTEXT:
11925 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11926
11927 //fall through
11928 default:
11929 3126010 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11930 3126010 break;
11931 }
11932 3126010 }
11933 3126010 }
11934
11935 12288 return 0;
11936 12288 }
11937
11938 2048 void reset_subscreen(subscreen_group *tempss)
11939 {
11940
2/2
✓ Branch 0 taken 524288 times.
✓ Branch 1 taken 2048 times.
526336 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11941 {
11942
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 524177 times.
524288 switch(tempss->objects[i].type)
11943 {
11944 case ssoTEXT:
11945 case ssoTEXTBOX:
11946 case ssoCURRENTITEMTEXT:
11947 case ssoCURRENTITEMCLASSTEXT:
11948
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
111 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11949
11950 //fall through
11951 default:
11952 524288 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11953 524288 break;
11954 }
11955 524288 }
11956 2048 }
11957
11958 16 void reset_subscreens()
11959 {
11960
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 16 times.
2064 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11961 {
11962 2048 reset_subscreen(&custom_subscreen[i]);
11963 2048 }
11964 16 }
11965
11966 16 int32_t setupsubscreens()
11967 {
11968 16 reset_subscreens();
11969 16 int32_t tempsubscreen=zinit.subscreen;
11970 subscreen_object *tempsub;
11971
11972
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempsubscreen>=ssdtMAX)
11973 {
11974 tempsubscreen=0;
11975 }
11976
11977
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
16 switch(tempsubscreen)
11978 {
11979 case ssdtOLD:
11980 case ssdtNEWSUBSCR:
11981 case ssdtREV2:
11982 case ssdtBSZELDA:
11983 case ssdtBSZELDAMODIFIED:
11984 case ssdtBSZELDAENHANCED:
11985 case ssdtBSZELDACOMPLETE:
11986 {
11987 16 tempsub = default_subscreen_active[tempsubscreen][0];
11988 int32_t i;
11989
11990
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11991 {
11992
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 992 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
11993 {
11994 case ssoTEXT:
11995 case ssoTEXTBOX:
11996 case ssoCURRENTITEMTEXT:
11997 case ssoCURRENTITEMCLASSTEXT:
11998
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11999
12000 48 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12001 48 custom_subscreen[0].objects[i].dp1 = NULL;
12002 48 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12003 48 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12004 48 break;
12005
12006 case ssoLIFEMETER:
12007 {
12008 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12009
12010 if(get_bit(deprecated_rules, 12) != 0)
12011 custom_subscreen[0].objects[i].d3=1;
12012 else
12013 custom_subscreen[0].objects[i].d3=0;
12014
12015 break;
12016 }
12017 /*
12018 case ssoTRIFRAME:
12019 {
12020 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12021 custom_subscreen[0].objects[i].d1 = 8594;
12022 custom_subscreen[0].objects[i].d2 = 8;
12023 custom_subscreen[0].objects[i].d3 = 8771;
12024 custom_subscreen[0].objects[i].d4 = 8;
12025 custom_subscreen[0].objects[i].d5 = 1;
12026 custom_subscreen[0].objects[i].d6 = 1;
12027 break;
12028 }*/
12029
12030 default:
12031 992 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12032 992 break;
12033 }
12034 1040 }
12035
12036 16 custom_subscreen[0].ss_type=sstACTIVE;
12037 16 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12038 16 tempsub = default_subscreen_active[tempsubscreen][1];
12039
12040
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1040 times.
✓ Branch 3 taken 16 times.
1056 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12041 {
12042
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 976 times.
✗ Branch 2 not taken.
1040 switch(tempsub[i].type)
12043 {
12044 case ssoTEXT:
12045 case ssoTEXTBOX:
12046 case ssoCURRENTITEMTEXT:
12047 case ssoCURRENTITEMCLASSTEXT:
12048
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12049
12050 64 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12051 64 custom_subscreen[1].objects[i].dp1 = NULL;
12052 64 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12053 64 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12054 64 break;
12055
12056 case ssoLIFEMETER:
12057 {
12058 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12059
12060 if(get_bit(deprecated_rules, 12) != 0)
12061 custom_subscreen[1].objects[i].d3=1;
12062 else
12063 custom_subscreen[1].objects[i].d3=0;
12064
12065 break;
12066 }
12067 /*
12068 case ssoTRIFRAME:
12069 {
12070 custom_subscreen[1].objects[i].d1 = 8594;
12071 custom_subscreen[1].objects[i].d2 = 8;
12072 custom_subscreen[1].objects[i].d3 = 8771;
12073 custom_subscreen[1].objects[i].d4 = 8;
12074 custom_subscreen[1].objects[i].d5 = 1;
12075 custom_subscreen[1].objects[i].d6 = 1;
12076 break;
12077 }*/
12078
12079 default:
12080 976 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12081 976 break;
12082 }
12083 1040 }
12084
12085 16 custom_subscreen[1].ss_type=sstACTIVE;
12086 16 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12087 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12088 16 tempsub = default_subscreen_passive[tempsubscreen][0];
12089
12090
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 16 times.
336 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12091 {
12092
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 16 times.
320 switch(tempsub[i].type)
12093 {
12094 case ssoTEXT:
12095 case ssoTEXTBOX:
12096 case ssoCURRENTITEMTEXT:
12097 case ssoCURRENTITEMCLASSTEXT:
12098
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12099
12100 48 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12101 48 custom_subscreen[2].objects[i].dp1 = NULL;
12102 48 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12103 48 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12104 48 break;
12105
12106 case ssoLIFEMETER:
12107 {
12108 16 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12109
12110
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12111 3 custom_subscreen[2].objects[i].d3=1;
12112 else
12113 13 custom_subscreen[2].objects[i].d3=0;
12114
12115 16 break;
12116 }
12117
12118 default:
12119 256 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12120 256 break;
12121 }
12122 320 }
12123
12124 16 custom_subscreen[2].ss_type=sstPASSIVE;
12125 16 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12126 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12127 16 tempsub = default_subscreen_passive[tempsubscreen][1];
12128
12129
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 304 times.
✓ Branch 3 taken 16 times.
320 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12130 {
12131
3/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 16 times.
304 switch(tempsub[i].type)
12132 {
12133 case ssoTEXT:
12134 case ssoTEXTBOX:
12135 case ssoCURRENTITEMTEXT:
12136 case ssoCURRENTITEMCLASSTEXT:
12137
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12138
12139 48 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12140 48 custom_subscreen[3].objects[i].dp1 = NULL;
12141 48 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12142 48 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12143 48 break;
12144
12145 case ssoLIFEMETER:
12146 {
12147 16 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12148
12149
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 13 times.
16 if(get_bit(deprecated_rules, 12) != 0)
12150 3 custom_subscreen[3].objects[i].d3=1;
12151 else
12152 13 custom_subscreen[3].objects[i].d3=0;
12153
12154 16 break;
12155 }
12156
12157 default:
12158 240 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12159 240 break;
12160 }
12161 304 }
12162
12163 16 custom_subscreen[3].ss_type=sstPASSIVE;
12164 16 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12165 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12166 16 break;
12167 }
12168
12169 case ssdtZ3:
12170 {
12171 tempsub = z3_active_a;
12172 int32_t i;
12173
12174 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12175 {
12176 switch(tempsub[i].type)
12177 {
12178 case ssoTEXT:
12179 case ssoTEXTBOX:
12180 case ssoCURRENTITEMTEXT:
12181 case ssoCURRENTITEMCLASSTEXT:
12182 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12183
12184 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12185 custom_subscreen[0].objects[i].dp1 = NULL;
12186 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12187 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12188 break;
12189
12190 case ssoLIFEMETER:
12191 {
12192 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12193
12194 if(get_bit(deprecated_rules, 12) != 0)
12195 custom_subscreen[0].objects[i].d3=1;
12196 else
12197 custom_subscreen[0].objects[i].d3=0;
12198
12199 break;
12200 }
12201
12202 default:
12203 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12204 break;
12205 }
12206 }
12207
12208 custom_subscreen[0].ss_type=sstACTIVE;
12209 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12210 tempsub = z3_active_ab;
12211
12212 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12213 {
12214 switch(tempsub[i].type)
12215 {
12216 case ssoTEXT:
12217 case ssoTEXTBOX:
12218 case ssoCURRENTITEMTEXT:
12219 case ssoCURRENTITEMCLASSTEXT:
12220 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12221
12222 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12223 custom_subscreen[1].objects[i].dp1 = NULL;
12224 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12225 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12226 break;
12227
12228 case ssoLIFEMETER:
12229 {
12230 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12231
12232 if(get_bit(deprecated_rules, 12) != 0)
12233 custom_subscreen[1].objects[i].d3=1;
12234 else
12235 custom_subscreen[1].objects[i].d3=0;
12236
12237 break;
12238 }
12239
12240 default:
12241 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12242 break;
12243 }
12244 }
12245
12246 custom_subscreen[1].ss_type=sstACTIVE;
12247 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12248 tempsub = z3_passive_a;
12249
12250 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12251 {
12252 switch(tempsub[i].type)
12253 {
12254 case ssoTEXT:
12255 case ssoTEXTBOX:
12256 case ssoCURRENTITEMTEXT:
12257 case ssoCURRENTITEMCLASSTEXT:
12258 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12259
12260 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12261 custom_subscreen[2].objects[i].dp1 = NULL;
12262 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12263 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12264 break;
12265
12266 case ssoLIFEMETER:
12267 {
12268 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12269
12270 if(get_bit(deprecated_rules, 12) != 0)
12271 custom_subscreen[2].objects[i].d3=1;
12272 else
12273 custom_subscreen[2].objects[i].d3=0;
12274
12275 break;
12276 }
12277
12278 default:
12279 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12280 break;
12281 }
12282 }
12283
12284 custom_subscreen[2].ss_type=sstPASSIVE;
12285 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12286 tempsub = z3_passive_ab;
12287
12288 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12289 {
12290 switch(tempsub[i].type)
12291 {
12292 case ssoTEXT:
12293 case ssoTEXTBOX:
12294 case ssoCURRENTITEMTEXT:
12295 case ssoCURRENTITEMCLASSTEXT:
12296 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12297
12298 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12299 custom_subscreen[3].objects[i].dp1 = NULL;
12300 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12301 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12302 break;
12303
12304 case ssoLIFEMETER:
12305 {
12306 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12307
12308 if(get_bit(deprecated_rules, 12) != 0)
12309 custom_subscreen[3].objects[i].d3=1;
12310 else
12311 custom_subscreen[3].objects[i].d3=0;
12312
12313 break;
12314 }
12315
12316 default:
12317 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12318 break;
12319 }
12320 }
12321
12322 custom_subscreen[3].ss_type=sstPASSIVE;
12323 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12324 break;
12325 }
12326 }
12327
12328
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 64 times.
80 for(int32_t i=0; i<4; ++i)
12329 {
12330 64 purge_blank_subscreen_objects(&custom_subscreen[i]);
12331 64 }
12332
12333 16 return 0;
12334 }
12335
12336 extern script_data *ffscripts[NUMSCRIPTFFC];
12337 extern script_data *itemscripts[NUMSCRIPTITEM];
12338 extern script_data *guyscripts[NUMSCRIPTGUYS];
12339 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12340 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12341 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12342 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12343 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12344 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12345 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12346 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12347 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12348 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12349 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12350
12351
12352
12353 96 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12354 {
12355 int32_t dummy;
12356 96 word s_version=0, s_cversion=0, zmeta_version=0;
12357 96 byte numscripts=0;
12358 96 numscripts=numscripts; //to avoid unused variables warnings
12359 int32_t ret;
12360
12361 //section version info
12362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
12363 {
12364 return qe_invalid;
12365 }
12366
12367 96 FFCore.quest_format[vFFScript] = s_version;
12368
12369
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
12370 {
12371 return qe_invalid;
12372 }
12373
12374
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 18)
12375 {
12376
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&zmeta_version,f,true))
12377 {
12378 return qe_invalid;
12379 }
12380 22 }
12381
12382 //al_trace("Scripts version %d\n", s_version);
12383 //section size
12384
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
12385 {
12386 return qe_invalid;
12387 }
12388
12389 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12390 96 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12391 96 temp_ffscript_version = s_version;
12392 //miscQdata *the_misc;
12393
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12394 96 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12395
12396 //finally... section data
12397
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12398 {
12399 49152 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12400
12401
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(ret != 0) return qe_invalid;
12402 49152 }
12403
12404 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12405 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12406 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12407 * there was a version bump a week before a change that broke stuff.
12408 */
12409
6/8
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 74 times.
96 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12410 {
12411 74 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12412 74 }
12413
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
96 if(s_version < 19 && keepdata)
12414 {
12415 74 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12416 74 }
12417
12418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 1)
12419 {
12420
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12421 {
12422 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12423
12424
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12425 24576 }
12426
12427
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12428 {
12429 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12430
12431
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12432 24576 }
12433
12434
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12435 {
12436 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12437
12438
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12439 24576 }
12440
12441
12442
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12443 {
12444 24576 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12445
12446
1/2
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
24576 if(ret != 0) return qe_invalid;
12447 24576 }
12448
12449
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 16)
12450 {
12451
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
198 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12452 {
12453 176 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12454
12455
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(ret != 0) return qe_invalid;
12456 176 }
12457 22 }
12458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 else if(s_version > 13)
12459 {
12460 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12461 {
12462 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12463
12464 if(ret != 0) return qe_invalid;
12465 }
12466
12467 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12468 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12469
12470 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12471 }
12472
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 else if(s_version > 4)
12473 {
12474
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12475 {
12476 296 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12477
12478
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(ret != 0) return qe_invalid;
12479 296 }
12480
12481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12482
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12483
12484
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12485
12486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12487
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12488
12489
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12490
12491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12492
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_F6];
12493
12494
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12495
12496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12497
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12498
12499
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12500 74 }
12501 else
12502 {
12503 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12504 {
12505 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12506
12507 if(ret != 0) return qe_invalid;
12508 }
12509
12510 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12511 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12512
12513 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12514
12515 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12516 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12517
12518 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12519
12520 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12521 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12522
12523 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12524
12525 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12526 delete globalscripts[GLOBAL_SCRIPT_F6];
12527
12528 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12529
12530 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12531 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12532
12533 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12534 }
12535
12536
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(s_version > 10) //expanded the number of Player scripts to 5.
12537 {
12538
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 22 times.
132 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12539 {
12540 110 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12541
12542
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(ret != 0) return qe_invalid;
12543 110 }
12544 22 }
12545 else
12546 {
12547
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12548 {
12549 222 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12550
12551
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(ret != 0) return qe_invalid;
12552 222 }
12553
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[3] != NULL)
12554
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete playerscripts[3];
12555
12556
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[3] = new script_data();
12557
12558
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[4] != NULL)
12559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 delete playerscripts[4];
12560
12561
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[4] = new script_data();
12562 }
12563
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
96 if(s_version > 8 && s_version < 10)
12564 {
12565
12566 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12567 {
12568 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12569
12570 if(ret != 0) return qe_invalid;
12571 }
12572 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12573 {
12574 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12575
12576 if(ret != 0) return qe_invalid;
12577 }
12578
12579 }
12580
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 10)
12581 {
12582
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12583 {
12584 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12585
12586
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12587 5632 }
12588
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12589 {
12590 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12591
12592
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12593 5632 }
12594
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12595 {
12596 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12597
12598
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12599 5632 }
12600
12601 22 }
12602
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=12)
12603 {
12604
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12605 {
12606 5632 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12607
12608
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(ret != 0) return qe_invalid;
12609 5632 }
12610 22 }
12611
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >=15)
12612 {
12613
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12614 {
12615 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12616
12617
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12618 11264 }
12619 22 }
12620
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >19)
12621 {
12622 22 word numgenscripts = NUMSCRIPTSGENERIC;
12623
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetw(&numgenscripts,f,true))
12624 {
12625 return qe_invalid;
12626 }
12627
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 22 times.
11286 for(int32_t i = 0; i < numgenscripts; i++)
12628 {
12629 11264 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12630
12631
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(ret != 0) return qe_invalid;
12632 11264 }
12633 22 }
12634
12635 /*
12636 else //Is this trip really necessary?
12637 {
12638 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12639 {
12640
12641 ewpnscripts[i] = NULL;
12642 }
12643 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12644 {
12645 dmapscripts[i] = NULL;
12646 }
12647 }
12648 */
12649
12650 96 }
12651
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 2)
12653 {
12654 int32_t bufsize;
12655 96 p_igetl(&bufsize, f, true);
12656 96 char * buf = new char[bufsize+1];
12657 96 pfread(buf, bufsize, f, true);
12658 96 buf[bufsize]=0;
12659
12660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
12661
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 zScript = string(buf);
12662
12663
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 delete[] buf;
12664 word numffcbindings;
12665 96 p_igetw(&numffcbindings, f, true);
12666
12667
2/2
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 96 times.
1066 for(int32_t i=0; i<numffcbindings; i++)
12668 {
12669 word id;
12670 970 p_igetw(&id, f, true);
12671 970 p_igetl(&bufsize, f, true);
12672 970 buf = new char[bufsize+1];
12673 970 pfread(buf, bufsize, f, true);
12674 970 buf[bufsize]=0;
12675
12676 //fix for buggy older saved quests -DD
12677
2/4
✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 970 times.
970 if(keepdata && id < NUMSCRIPTFFC-1)
12678 970 ffcmap[id].scriptname = buf;
12679
12680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 delete[] buf;
12681 970 }
12682
12683 word numglobalbindings;
12684 96 p_igetw(&numglobalbindings, f, true);
12685
12686
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 96 times.
494 for(int32_t i=0; i<numglobalbindings; i++)
12687 {
12688 word id;
12689 398 p_igetw(&id, f, true);
12690 398 p_igetl(&bufsize, f, true);
12691 398 buf = new char[bufsize+1];
12692 398 pfread(buf, bufsize, f, true);
12693 398 buf[bufsize]=0;
12694
12695 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12696 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12697 // Ignore these. -DD
12698
4/6
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 239 times.
398 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12699 {
12700 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12701
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if(strcmp(buf,"~Continue") == 0)
12702 {
12703 globalmap[id].scriptname = "";
12704
12705 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12706 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12707 }
12708 else
12709 {
12710 239 globalmap[id].scriptname = buf;
12711 }
12712 239 }
12713
12714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 delete[] buf;
12715 398 }
12716
12717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version > 3)
12718 {
12719 word numitembindings;
12720 96 p_igetw(&numitembindings, f, true);
12721
12722
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 96 times.
177 for(int32_t i=0; i<numitembindings; i++)
12723 {
12724 word id;
12725 81 p_igetw(&id, f, true);
12726 81 p_igetl(&bufsize, f, true);
12727 81 buf = new char[bufsize+1];
12728 81 pfread(buf, bufsize, f, true);
12729 81 buf[bufsize]=0;
12730
12731 //fix this too
12732
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && id <NUMSCRIPTITEM-1)
12733 81 itemmap[id].scriptname = buf;
12734
12735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 delete[] buf;
12736 81 }
12737 96 }
12738 //(v9+)
12739
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 8)
12740 {
12741 //npc scripts
12742 word numnpcbindings;
12743 22 p_igetw(&numnpcbindings, f, true);
12744
12745
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 22 times.
34 for(int32_t i=0; i<numnpcbindings; i++)
12746 {
12747 word id;
12748 12 p_igetw(&id, f, true);
12749 12 p_igetl(&bufsize, f, true);
12750 12 buf = new char[bufsize+1];
12751 12 pfread(buf, bufsize, f, true);
12752 12 buf[bufsize]=0;
12753
12754 //fix this too
12755
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12756 12 npcmap[id].scriptname = buf;
12757
12758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12759 12 }
12760 //lweapon
12761 word numlwpnbindings;
12762 22 p_igetw(&numlwpnbindings, f, true);
12763
12764
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 22 times.
64 for(int32_t i=0; i<numlwpnbindings; i++)
12765 {
12766 word id;
12767 42 p_igetw(&id, f, true);
12768 42 p_igetl(&bufsize, f, true);
12769 42 buf = new char[bufsize+1];
12770 42 pfread(buf, bufsize, f, true);
12771 42 buf[bufsize]=0;
12772
12773 //fix this too
12774
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12775 42 lwpnmap[id].scriptname = buf;
12776
12777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12778 42 }
12779 //eweapon
12780 word numewpnbindings;
12781 22 p_igetw(&numewpnbindings, f, true);
12782
12783
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 22 times.
85 for(int32_t i=0; i<numewpnbindings; i++)
12784 {
12785 word id;
12786 63 p_igetw(&id, f, true);
12787 63 p_igetl(&bufsize, f, true);
12788 63 buf = new char[bufsize+1];
12789 63 pfread(buf, bufsize, f, true);
12790 63 buf[bufsize]=0;
12791
12792 //fix this too
12793
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12794 63 ewpnmap[id].scriptname = buf;
12795
12796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12797 63 }
12798 //hero
12799 word numherobindings;
12800 22 p_igetw(&numherobindings, f, true);
12801
12802
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22 times.
26 for(int32_t i=0; i<numherobindings; i++)
12803 {
12804 word id;
12805 4 p_igetw(&id, f, true);
12806 4 p_igetl(&bufsize, f, true);
12807 4 buf = new char[bufsize+1];
12808 4 pfread(buf, bufsize, f, true);
12809 4 buf[bufsize]=0;
12810
12811 //fix this too
12812
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12813 4 playermap[id].scriptname = buf;
12814
12815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12816 4 }
12817 //dmaps
12818 word numdmapbindings;
12819 22 p_igetw(&numdmapbindings, f, true);
12820
12821
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numdmapbindings; i++)
12822 {
12823 word id;
12824 14 p_igetw(&id, f, true);
12825 14 p_igetl(&bufsize, f, true);
12826 14 buf = new char[bufsize+1];
12827 14 pfread(buf, bufsize, f, true);
12828 14 buf[bufsize]=0;
12829
12830 //fix this too
12831
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12832 14 dmapmap[id].scriptname = buf;
12833
12834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12835 14 }
12836 //screen
12837 word numscreenbindings;
12838 22 p_igetw(&numscreenbindings, f, true);
12839
12840
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 22 times.
33 for(int32_t i=0; i<numscreenbindings; i++)
12841 {
12842 word id;
12843 11 p_igetw(&id, f, true);
12844 11 p_igetl(&bufsize, f, true);
12845 11 buf = new char[bufsize+1];
12846 11 pfread(buf, bufsize, f, true);
12847 11 buf[bufsize]=0;
12848
12849 //fix this too
12850
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12851 11 screenmap[id].scriptname = buf;
12852
12853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12854 11 }
12855 22 }
12856
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 11)
12857 {
12858 word numspritebindings;
12859 22 p_igetw(&numspritebindings, f, true);
12860
12861
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 22 times.
32 for(int32_t i=0; i<numspritebindings; i++)
12862 {
12863 word id;
12864 10 p_igetw(&id, f, true);
12865 10 p_igetl(&bufsize, f, true);
12866 10 buf = new char[bufsize+1];
12867 10 pfread(buf, bufsize, f, true);
12868 10 buf[bufsize]=0;
12869
12870 //fix this too
12871
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
12872 10 itemspritemap[id].scriptname = buf;
12873
12874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12875 10 }
12876 22 }
12877
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version >= 15)
12878 {
12879 word numcombobindings;
12880 22 p_igetw(&numcombobindings, f, true);
12881
12882
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 22 times.
46 for(int32_t i=0; i<numcombobindings; i++)
12883 {
12884 word id;
12885 24 p_igetw(&id, f, true);
12886 24 p_igetl(&bufsize, f, true);
12887 24 buf = new char[bufsize+1];
12888 24 pfread(buf, bufsize, f, true);
12889 24 buf[bufsize]=0;
12890
12891 //fix this too
12892
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12893 24 comboscriptmap[id].scriptname = buf;
12894
12895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
12896 24 }
12897 22 }
12898
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 22 times.
96 if(s_version > 19)
12899 {
12900 word numgenericbindings;
12901 22 p_igetw(&numgenericbindings, f, true);
12902
12903
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 for(int32_t i=0; i<numgenericbindings; i++)
12904 {
12905 word id;
12906 14 p_igetw(&id, f, true);
12907 14 p_igetl(&bufsize, f, true);
12908 14 buf = new char[bufsize+1];
12909 14 pfread(buf, bufsize, f, true);
12910 14 buf[bufsize]=0;
12911
12912 //fix this too
12913
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12914 14 genericmap[id].scriptname = buf;
12915
12916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12917 14 }
12918 22 }
12919 96 }
12920
12921 96 return 0;
12922 96 }
12923
12924 99 void reset_scripts()
12925 {
12926 //OK, who spaced this? ;)
12927
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12928 {
12929
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(ffscripts[i]!=NULL) delete ffscripts[i];
12930 50688 }
12931
12932
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12933 {
12934
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemscripts[i]!=NULL) delete itemscripts[i];
12935 25344 }
12936
12937
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12938 {
12939
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(guyscripts[i]!=NULL) delete guyscripts[i];
12940 25344 }
12941
12942
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12943 {
12944
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12945 25344 }
12946
12947
12948
12949
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12950 {
12951
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(screenscripts[i]!=NULL) delete screenscripts[i];
12952 25344 }
12953
12954
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12955 {
12956
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 792 times.
792 if(globalscripts[i]!=NULL) delete globalscripts[i];
12957 792 }
12958
12959
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12960 {
12961
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 495 times.
495 if(playerscripts[i]!=NULL) delete playerscripts[i];
12962 495 }
12963
12964
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12965 {
12966
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12967 25344 }
12968
12969
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12970 {
12971
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12972 25344 }
12973
12974
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12975 {
12976
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12977 25344 }
12978
12979
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12980 {
12981
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25344 times.
25344 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12982 25344 }
12983
12984
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12985 {
12986
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 50688 times.
50688 if(comboscripts[i]!=NULL) delete comboscripts[i];
12987 50688 }
12988
12989 99 next_script_data_debug_id = 0;
12990
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12991 {
12992
3/4
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 35840 times.
✓ Branch 2 taken 35840 times.
✗ Branch 3 not taken.
50688 if(genericscripts[i]!=NULL) delete genericscripts[i];
12993
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 genericscripts[i] = new script_data();
12994 50688 }
12995
12996
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12997 {
12998
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 ffscripts[i] = new script_data();
12999 50688 }
13000
13001
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13002 {
13003
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemscripts[i] = new script_data();
13004 25344 }
13005
13006
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13007 {
13008
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 guyscripts[i] = new script_data();
13009 25344 }
13010
13011
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13012 {
13013
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 wpnscripts[i] = new script_data();
13014 25344 }
13015
13016
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13017 {
13018
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 screenscripts[i] = new script_data();
13019 25344 }
13020
13021
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 99 times.
891 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13022 {
13023
1/2
✓ Branch 0 taken 792 times.
✗ Branch 1 not taken.
792 globalscripts[i] = new script_data();
13024 792 }
13025
13026
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 99 times.
594 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13027 {
13028
1/2
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
495 playerscripts[i] = new script_data();
13029 495 }
13030
13031
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13032 {
13033
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 lwpnscripts[i] = new script_data();
13034 25344 }
13035
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13036 {
13037
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 ewpnscripts[i] = new script_data();
13038 25344 }
13039
13040
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13041 {
13042
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 dmapscripts[i] = new script_data();
13043 25344 }
13044
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13045 {
13046
1/2
✓ Branch 0 taken 25344 times.
✗ Branch 1 not taken.
25344 itemspritescripts[i] = new script_data();
13047 25344 }
13048
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13049 {
13050
1/2
✓ Branch 0 taken 50688 times.
✗ Branch 1 not taken.
50688 comboscripts[i] = new script_data();
13051 50688 }
13052 99 }
13053
13054 extern script_command command_list[];
13055 193316 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13056 {
13057 //Please also update loadquest() when modifying this method -DD
13058 193316 char b33[34] = {0};
13059 193316 b33[33] = 0;
13060 193316 ffscript temp_script;
13061 193316 int32_t num_commands=1000;
13062
13063
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(s_version>=2)
13064 {
13065
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 if(!p_igetl(&num_commands,f,true))
13066 {
13067 return qe_invalid;
13068 }
13069 193316 }
13070
13071
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13072 {
13073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193316 times.
193316 delete (*script);
13075
2/4
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 193316 times.
✗ Branch 3 not taken.
193316 (*script) = new script_data(num_commands);
13076 193316 }
13077
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 114182 times.
193316 if(s_version >= 16)
13078 {
13079
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 zasm_meta temp_meta;
13080
13081
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13082 {
13083 return qe_invalid;
13084 }
13085
13086
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.meta_v),f,true))
13087 {
13088 return qe_invalid;
13089 }
13090
13091
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13092 {
13093 return qe_invalid;
13094 }
13095
13096
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.script_type),f,true))
13097 {
13098 return qe_invalid;
13099 }
13100
13101
2/2
✓ Branch 0 taken 633072 times.
✓ Branch 1 taken 79134 times.
712206 for(int32_t q = 0; q < 8; ++q)
13102 {
13103
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 431640 times.
633072 if(zmeta_version < 3)
13104 {
13105
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 6647256 times.
6848688 for(int32_t c = 0; c < 33; ++c)
13106 {
13107
2/4
✓ Branch 0 taken 6647256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6647256 times.
✗ Branch 3 not taken.
6647256 if(!p_getc(&(b33[c]),f,true))
13108 {
13109 return qe_invalid;
13110 }
13111 6647256 }
13112
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.run_idens[q].assign(b33);
13113 201432 }
13114 else
13115 {
13116
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13117 {
13118 return qe_invalid;
13119 }
13120 }
13121 633072 }
13122
13123
2/2
✓ Branch 0 taken 79134 times.
✓ Branch 1 taken 633072 times.
712206 for(int32_t q = 0; q < 8; ++q)
13124 {
13125
2/4
✓ Branch 0 taken 633072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 633072 times.
✗ Branch 3 not taken.
633072 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13126 {
13127 return qe_invalid;
13128 }
13129 633072 }
13130
13131
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_getc(&(temp_meta.flags),f,true))
13132 {
13133 return qe_invalid;
13134 }
13135
13136
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13137 {
13138 return qe_invalid;
13139 }
13140
13141
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13142 {
13143 return qe_invalid;
13144 }
13145
13146
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13147 {
13148 return qe_invalid;
13149 }
13150
13151
2/4
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79134 times.
✗ Branch 3 not taken.
79134 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13152 {
13153 return qe_invalid;
13154 }
13155
13156
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 53955 times.
79134 if(zmeta_version == 2)
13157 {
13158
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13159 {
13160
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13161 {
13162 return qe_invalid;
13163 }
13164 830907 }
13165
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.script_name.assign(b33);
13166
13167
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 830907 times.
856086 for(int32_t c = 0; c < 33; ++c)
13168 {
13169
2/4
✓ Branch 0 taken 830907 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 830907 times.
✗ Branch 3 not taken.
830907 if(!p_getc(&b33[c],f,true))
13170 {
13171 return qe_invalid;
13172 }
13173 830907 }
13174
1/2
✓ Branch 0 taken 25179 times.
✗ Branch 1 not taken.
25179 temp_meta.author.assign(b33);
13175 25179 }
13176
1/2
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
53955 else if(zmeta_version > 2)
13177 {
13178
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.script_name,f,true))
13179 return qe_invalid;
13180
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.author,f,true))
13181 return qe_invalid;
13182 53955 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13183
2/2
✓ Branch 0 taken 539550 times.
✓ Branch 1 taken 53955 times.
593505 for(auto q = 0; q < num_meta_attrib; ++q)
13184 {
13185
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13186 return qe_invalid;
13187
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13188 return qe_invalid;
13189 539550 }
13190
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13191 {
13192
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13193 return qe_invalid;
13194
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13195 return qe_invalid;
13196 431640 }
13197
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13198 {
13199
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13200 return qe_invalid;
13201
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13202 return qe_invalid;
13203 431640 }
13204
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 53955 times.
917235 for(auto q = 0; q < 16; ++q)
13205 {
13206
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13207 return qe_invalid;
13208
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13209 return qe_invalid;
13210 863280 }
13211 53955 }
13212
2/2
✓ Branch 0 taken 53955 times.
✓ Branch 1 taken 25179 times.
79134 if(zmeta_version > 3)
13213 {
13214
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13215 {
13216
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.initd[q],f,true))
13217 return qe_invalid;
13218
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13219 return qe_invalid;
13220 431640 }
13221
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13222 {
13223
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getc(&temp_meta.initd_type[q],f,true))
13224 return qe_invalid;
13225 431640 }
13226 53955 }
13227 else
13228 {
13229
2/2
✓ Branch 0 taken 201432 times.
✓ Branch 1 taken 25179 times.
226611 for(auto q = 0; q < 8; ++q)
13230 {
13231
1/2
✓ Branch 0 taken 201432 times.
✗ Branch 1 not taken.
201432 temp_meta.initd[q] = temp_meta.run_idens[q];
13232 201432 }
13233 }
13234
13235
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 if(keepdata)
13236
1/2
✓ Branch 0 taken 79134 times.
✗ Branch 1 not taken.
79134 (*script)->meta = temp_meta;
13237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79134 times.
79134 }
13238
13239
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 temp_script.clear();
13240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7767709 times.
7767709 for(int32_t j=0; j<num_commands; j++)
13241 {
13242
2/4
✓ Branch 0 taken 7767709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7767709 times.
✗ Branch 3 not taken.
7767709 if(!p_igetw(&(temp_script.command),f,true))
13243 {
13244 return qe_invalid;
13245 }
13246
13247
2/2
✓ Branch 0 taken 7574393 times.
✓ Branch 1 taken 193316 times.
7767709 if(temp_script.command == 0xFFFF)
13248 {
13249
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 if(keepdata)
13250
1/2
✓ Branch 0 taken 193316 times.
✗ Branch 1 not taken.
193316 (*script)->zasm[j].clear();
13251 193316 break;
13252 }
13253 else
13254 {
13255
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13256 {
13257 return qe_invalid;
13258 }
13259
13260
2/4
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574393 times.
✗ Branch 3 not taken.
7574393 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13261 {
13262 return qe_invalid;
13263 }
13264
13265
2/2
✓ Branch 0 taken 451725 times.
✓ Branch 1 taken 7122668 times.
7574393 if(s_version >= 21)
13266 {
13267 451725 uint32_t sz = 0;
13268
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13269 {
13270 return qe_invalid;
13271 }
13272
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450203 times.
451725 if(sz) //string found
13273 {
13274
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13275 char dummy;
13276
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13277 {
13278
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13279 {
13280 return qe_invalid;
13281 }
13282
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13283 115152 }
13284 1522 }
13285
2/4
✓ Branch 0 taken 451725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451725 times.
✗ Branch 3 not taken.
451725 if(!p_igetl(&sz,f,keepdata))
13286 {
13287 return qe_invalid;
13288 }
13289
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451635 times.
451725 if(sz) //vector found
13290 {
13291
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13292 int32_t dummy;
13293
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13294 {
13295
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13296 {
13297 return qe_invalid;
13298 }
13299
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13300 1311 }
13301 90 }
13302 451725 }
13303
13304
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 if(keepdata)
13305 {
13306
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.give((*script)->zasm[j]);
13307 7574393 }
13308 }
13309
1/2
✓ Branch 0 taken 7574393 times.
✗ Branch 1 not taken.
7574393 temp_script.clear();
13310 7574393 }
13311
13312 193316 return 0;
13313 193316 }
13314
13315 extern SAMPLE customsfxdata[WAV_COUNT];
13316 extern uint8_t customsfxflag[WAV_COUNT>>3];
13317 extern int32_t sfxdat;
13318 extern DATAFILE *sfxdata;
13319 const char *old_sfx_string[Z35] =
13320 {
13321 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13322 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13323 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13324 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13325 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13326 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13327 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13328 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13329 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13330 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13331 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13332 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13333 };
13334 char *sfx_string[WAV_COUNT];
13335
13336 96 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13337 {
13338 //these are here to bypass compiler warnings about unused arguments
13339 96 Header=Header;
13340
13341 int32_t dummy;
13342 96 word s_version=0, s_cversion=0;
13343 //int32_t ret;
13344 SAMPLE temp_sample;
13345 96 temp_sample.loop_start=0;
13346 96 temp_sample.loop_end=0;
13347 96 temp_sample.param=0;
13348
13349 //section version info
13350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
13351 {
13352 return qe_invalid;
13353 }
13354
13355 96 FFCore.quest_format[vSFX] = s_version;
13356
13357 //al_trace("SFX version %d\n", s_version);
13358
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
13359 {
13360 return qe_invalid;
13361 }
13362
13363 //section size
13364
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
13365 {
13366 return qe_invalid;
13367 }
13368
13369 /* HIGHLY UNORTHODOX UPDATING THING, by L
13370 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13371 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13372 * changing from 1 to 2.
13373 */
13374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96 if(s_version < 2 && keepdata)
13375 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13376
13377 /* End highly unorthodox updating thing */
13378
13379 96 int32_t wavcount = WAV_COUNT;
13380
13381
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13382 wavcount = 128;
13383
13384 uint8_t tempflag[WAV_COUNT>>3];
13385
13386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version < 4)
13387 {
13388 memset(tempflag, 0xFF, WAV_COUNT>>3);
13389 }
13390 else
13391 {
13392
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version < 6)
13393 memset(tempflag, 0, WAV_COUNT>>3);
13394
13395
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 96 times.
3168 for(int32_t i=0; i<(wavcount>>3); i++)
13396 {
13397 3072 p_getc(&tempflag[i], f, true);
13398 3072 }
13399
13400 }
13401
13402
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(s_version>4)
13403 {
13404
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<WAV_COUNT; i++)
13405 {
13406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(keepdata)
13407 {
13408 24480 sprintf(sfx_string[i],"s%03d",i);
13409
13410
2/2
✓ Branch 0 taken 18720 times.
✓ Branch 1 taken 5760 times.
24480 if((i<Z35))
13411 5760 strcpy(sfx_string[i], old_sfx_string[i-1]);
13412 24480 }
13413
13414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
24480 if(i>=wavcount)
13415 continue;
13416
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13417 {
13418 char tempname[36];
13419
13420
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!pfread(tempname, 36, f, keepdata))
13421 {
13422 return qe_invalid;
13423 }
13424
13425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(keepdata)
13426 {
13427 1835 strcpy(sfx_string[i], tempname);
13428 1835 sfx_string[i][35] = 0; //Force NULL Termination
13429 1835 }
13430 1835 }
13431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22645 times.
22645 else if(keepdata)
13432 {
13433 22645 sprintf(sfx_string[i],"s%03d",i);
13434
13435
2/2
✓ Branch 0 taken 18224 times.
✓ Branch 1 taken 4421 times.
22645 if(i<Z35)
13436 4421 strcpy(sfx_string[i], old_sfx_string[i-1]);
13437 22645 sfx_string[i][35] = 0; //Force NULL Termination
13438 22645 }
13439 24480 }
13440 96 }
13441 else
13442 {
13443 if(keepdata)
13444 {
13445 for(int32_t i=1; i<WAV_COUNT; i++)
13446 {
13447 sprintf(sfx_string[i],"s%03d",i);
13448
13449 if(i<Z35)
13450 strcpy(sfx_string[i], old_sfx_string[i-1]);
13451 }
13452 }
13453 }
13454
13455 //finally... section data
13456
2/2
✓ Branch 0 taken 24480 times.
✓ Branch 1 taken 96 times.
24576 for(int32_t i=1; i<wavcount; i++)
13457 {
13458
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 22645 times.
24480 if(get_bit(tempflag, i-1))
13459 {
13460
13461
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13462 {
13463 return qe_invalid;
13464 }
13465
13466 1835 (temp_sample.bits) = dummy;
13467
13468
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,true))
13469 {
13470 return qe_invalid;
13471 }
13472
13473 1835 (temp_sample.stereo) = dummy;
13474
13475
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13476 {
13477 return qe_invalid;
13478 }
13479
13480 1835 (temp_sample.freq) = dummy;
13481
13482
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&dummy,f,keepdata))
13483 {
13484 return qe_invalid;
13485 }
13486
13487 1835 (temp_sample.priority) = dummy;
13488
13489
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.len),f,true))
13490 {
13491 return qe_invalid;
13492 }
13493
13494
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13495 {
13496 return qe_invalid;
13497 }
13498
13499
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13500 {
13501 return qe_invalid;
13502 }
13503
13504
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(!p_igetl(&(temp_sample.param),f,keepdata))
13505 {
13506 return qe_invalid;
13507 }
13508
13509 // al_trace("F%i: L%i\n",i,temp_sample.len);
13510 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13511 1835 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13512 1835 temp_sample.data = calloc(len,1);
13513
13514
1/2
✓ Branch 0 taken 1835 times.
✗ Branch 1 not taken.
1835 if(s_version < 3)
13515 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13516
13517 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835 times.
1835 if(s_version < 2)
13519 {
13520 if(!pfread(temp_sample.data, len,f,keepdata))
13521 {
13522 return qe_invalid;
13523 }
13524 }
13525 else
13526 {
13527 //re-endianfy the data
13528 1835 int32_t wordstoread = len / sizeof(word);
13529
13530
2/2
✓ Branch 0 taken 53693862 times.
✓ Branch 1 taken 1835 times.
53695697 for(int32_t j=0; j<wordstoread; j++)
13531 {
13532 word temp;
13533
13534
1/2
✓ Branch 0 taken 53693862 times.
✗ Branch 1 not taken.
53693862 if(!p_igetw(&temp, f, keepdata))
13535 {
13536 return qe_invalid;
13537 }
13538
13539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53693862 times.
53693862 if(keepdata)
13540 53693862 ((word *)temp_sample.data)[j] = temp;
13541 53693862 }
13542 }
13543 1835 }
13544
2/2
✓ Branch 0 taken 4421 times.
✓ Branch 1 taken 18224 times.
22645 else if(i < Z35)
13545 {
13546 4421 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13547 4421 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13548 4421 set_bit(tempflag, i-1, 1);
13549 4421 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13550 4421 temp_sample.data = calloc(len,1);
13551 4421 memcpy(temp_sample.data, datsamp->data, len);
13552 4421 }
13553 18224 else continue;
13554
13555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(keepdata)
13556 {
13557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6256 times.
6256 if(customsfxdata[i].data!=NULL)
13558 {
13559 // delete [] customsfxdata[i].data;
13560 6256 free(customsfxdata[i].data);
13561 6256 }
13562
13563 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13564 6256 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13565 6256 customsfxdata[i].data = calloc(len2,1);
13566 6256 customsfxdata[i].bits = temp_sample.bits;
13567 6256 customsfxdata[i].stereo = temp_sample.stereo;
13568 6256 customsfxdata[i].freq = temp_sample.freq;
13569 6256 customsfxdata[i].priority = temp_sample.priority;
13570 6256 customsfxdata[i].len = temp_sample.len;
13571 6256 customsfxdata[i].loop_start = temp_sample.loop_start;
13572 6256 customsfxdata[i].loop_end = temp_sample.loop_end;
13573 6256 customsfxdata[i].param = temp_sample.param;
13574 6256 int32_t cpylen = len2;
13575
13576
1/2
✓ Branch 0 taken 6256 times.
✗ Branch 1 not taken.
6256 if(s_version<3)
13577 {
13578 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13579 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13580 }
13581
13582 6256 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13583 6256 }
13584
13585 6256 free(temp_sample.data);
13586 6256 }
13587
13588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
13589 96 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13590
13591 96 sfxdat=0;
13592 96 return 0;
13593 96 }
13594
13595 99 void setupsfx()
13596 {
13597
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=1; i<WAV_COUNT; i++)
13598 {
13599 25245 sprintf(sfx_string[i],"s%03d",i);
13600
13601
2/2
✓ Branch 0 taken 19305 times.
✓ Branch 1 taken 5940 times.
25245 if(i<Z35)
13602 {
13603 5940 strcpy(sfx_string[i], old_sfx_string[i-1]);
13604 5940 }
13605
13606 25245 memset(customsfxflag, 0, WAV_COUNT>>3);
13607
13608 25245 int32_t j=i;
13609
13610
2/2
✓ Branch 0 taken 6039 times.
✓ Branch 1 taken 19206 times.
25245 if(i>Z35)
13611 {
13612 19206 i=Z35;
13613 19206 }
13614
13615 25245 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13616
13617
2/2
✓ Branch 0 taken 7395 times.
✓ Branch 1 taken 17850 times.
25245 if(customsfxdata[j].data!=NULL)
13618 {
13619 // delete [] customsfxdata[j].data;
13620 17850 free(customsfxdata[j].data);
13621 17850 }
13622
13623 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13624 25245 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13625 25245 customsfxdata[j].bits = temp_sample->bits;
13626 25245 customsfxdata[j].stereo = temp_sample->stereo;
13627 25245 customsfxdata[j].freq = temp_sample->freq;
13628 25245 customsfxdata[j].priority = temp_sample->priority;
13629 25245 customsfxdata[j].len = temp_sample->len;
13630 25245 customsfxdata[j].loop_start = temp_sample->loop_start;
13631 25245 customsfxdata[j].loop_end = temp_sample->loop_end;
13632 25245 customsfxdata[j].param = temp_sample->param;
13633 25245 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13634 25245 i=j;
13635 25245 }
13636 99 }
13637
13638 extern char *guy_string[eMAXGUYS];
13639 extern const char *old_guy_string[OLDMAXGUYS];
13640
13641 99 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13642 {
13643 dword dummy;
13644 word guy_cversion;
13645 99 word guyversion=0;
13646
13647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version >= 0x193)
13648 {
13649 //section version info
13650
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guyversion,f,true))
13651 {
13652 return qe_invalid;
13653 }
13654
13655 99 FFCore.quest_format[vGuys] = guyversion;
13656
13657 //al_trace("Guys version %d\n", guyversion);
13658
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&guy_cversion,f,true))
13659 {
13660 return qe_invalid;
13661 }
13662 99 al_trace("Guy CVersion is: %d\n", guy_cversion);
13663 //section size
13664
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
13665 {
13666 return qe_invalid;
13667 }
13668 99 }
13669
13670
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(guyversion > 3)
13671 {
13672
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13673 {
13674 char tempname[64];
13675
13676 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13677 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13678
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49152 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13679 {
13680 memset(tempname, 0, sizeof(char)*64);
13681 sprintf(tempname, "e%03d", i);
13682 strcpy(guy_string[i], tempname);
13683
13684 continue;
13685 }
13686
13687
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!pfread(tempname, 64, f, keepdata))
13688 {
13689 return qe_invalid;
13690 }
13691
13692 // Don't retain names of uneditable enemy entries!
13693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
13694 {
13695 // for version upgrade to 2.5
13696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && i >= 177)
13697 {
13698 // some of the older builds have names such as 'zz123',
13699 // (this order gets messed up with some eXXX and some zzXXX)
13700 // so let's update to the newer naming convection. -Gleeok
13701 char tmpbuf[64];
13702 memset(tmpbuf, 0, sizeof(char)*64);
13703 sprintf(tmpbuf, "zz%03d", i);
13704
13705 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13706 {
13707 memset(tempname, 0, sizeof(char)*64);
13708 sprintf(tempname, "e%03d", i);
13709 }
13710 }
13711
13712
6/6
✓ Branch 0 taken 16992 times.
✓ Branch 1 taken 32160 times.
✓ Branch 2 taken 16128 times.
✓ Branch 3 taken 864 times.
✓ Branch 4 taken 13280 times.
✓ Branch 5 taken 2848 times.
49152 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13713 {
13714 46304 strcpy(guy_string[i], tempname);
13715 46304 }
13716 else
13717 {
13718 2848 strcpy(guy_string[i],old_guy_string[i]);
13719 }
13720 49152 }
13721 49152 }
13722 96 }
13723 else
13724 {
13725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata)
13726 {
13727
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3 times.
1539 for(int32_t i=0; i<eMAXGUYS; i++)
13728 {
13729 1536 sprintf(guy_string[i],"zz%03d",i);
13730 1536 }
13731
13732
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3 times.
534 for(int32_t i=0; i<OLDMAXGUYS; i++)
13733 {
13734 531 strcpy(guy_string[i],old_guy_string[i]);
13735 531 }
13736 3 }
13737 }
13738
13739
13740 //finally... section data
13741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
13742 {
13743 99 init_guys(guyversion); //using default data for now...
13744
13745 // Goriya guy fix
13746
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13747 {
13748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13749 {
13750 3 guysbuf[gGORIYA].tile=130;
13751 3 guysbuf[gGORIYA].e_tile=130;
13752 3 }
13753 3 }
13754 99 }
13755
13756
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
13757 {
13758 if(get_bit(deprecated_rules,46))
13759 {
13760 guysbuf[eDODONGO].cset=14;
13761 guysbuf[eDODONGO].bosspal=spDIG;
13762 }
13763 }
13764 // Not sure when this first changed, but it's necessary for 2.10, at least
13765 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13766 //2.10 Fixes
13767
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13768 {
13769 3 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13770 3 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13771 3 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13772 3 guysbuf[eCENT1].misc3 = 1;
13773 3 guysbuf[eCENT2].misc3 = 1;
13774 3 }
13775
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13776 {
13777 99 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13778 99 }
13779
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version <= 0x210)
13780 {
13781 3 guysbuf[eGLEEOK1F].misc6 = 16;
13782 3 guysbuf[eGLEEOK2F].misc6 = 16;
13783 3 guysbuf[eGLEEOK3F].misc6 = 16;
13784 3 guysbuf[eGLEEOK4F].misc6 = 16;
13785
13786 3 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13787 3 guysbuf[eBATROBE].misc4 = 1;
13788 //guysbuf[eSUMMONER].misc4 = 1;
13789 3 guysbuf[eWWIZ].misc4 = 1;
13790 3 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13791 3 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13792 3 }
13793
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version == 0x190)
13794 {
13795 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13796 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13797 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13798 }
13799
13800 // The versions here may not be correct
13801 // zelda_version>=0x211 handled at guyversion<24
13802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version <= 0x190)
13803 {
13804 guysbuf[eCENT1].misc3 = 0;
13805 guysbuf[eCENT2].misc3 = 0;
13806 guysbuf[eMOLDORM].misc2 = 0;
13807 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13808 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13809 }
13810
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 else if(Header->zelda_version <= 0x210)
13811 {
13812 3 guysbuf[eCENT1].misc3 = 1;
13813 3 guysbuf[eCENT2].misc3 = 1;
13814 3 guysbuf[eMOLDORM].misc2 = 0;
13815 3 }
13816
13817
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13818 {
13819 3 guysbuf[eKEESE1].misc16 = 120;
13820 3 guysbuf[eKEESE2].misc16 = 120;
13821 3 guysbuf[eKEESE3].misc16 = 120;
13822 3 guysbuf[eKEESETRIB].misc16 = 120;
13823 3 guysbuf[eKEESE1].misc17 = 16;
13824 3 guysbuf[eKEESE2].misc17 = 16;
13825 3 guysbuf[eKEESE3].misc17 = 16;
13826 3 guysbuf[eKEESETRIB].misc17 = 16;
13827
13828 3 guysbuf[ePEAHAT].misc16 = 80;
13829 3 guysbuf[ePEAHAT].misc17 = 16;
13830
13831 3 guysbuf[eGHINI2].misc16 = 120;
13832 3 guysbuf[eGHINI2].misc17 = 10;
13833
13834 3 }
13835
13836
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(guyversion<=2)
13837 {
13838 3 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13839 }
13840
13841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(guyversion > 3)
13842 {
13843 guydata tempguy;
13844
13845
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXGUYS; i++)
13846 {
13847
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49152 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13848 {
13849 if(i >= OLDBETAMAXGUYS)
13850 {
13851 memset(&guysbuf[i], 0, sizeof(guydata));
13852 continue;
13853 }
13854 }
13855
13856 49152 memset(&tempguy, 0, sizeof(guydata));
13857
13858
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags),f,keepdata))
13859 {
13860 return qe_invalid;
13861 }
13862
13863
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13864 {
13865 return qe_invalid;
13866 }
13867
13868
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13869 {
13870
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tile),f,keepdata))
13871 {
13872 return qe_invalid;
13873 }
13874 11264 }
13875 else
13876 {
13877
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.tile),f,keepdata))
13878 {
13879 return qe_invalid;
13880 }
13881 }
13882
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.width),f,keepdata))
13883 {
13884 return qe_invalid;
13885 }
13886
13887
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.height),f,keepdata))
13888 {
13889 return qe_invalid;
13890 }
13891
13892
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13893 {
13894
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13895 {
13896 return qe_invalid;
13897 }
13898 11264 }
13899 else
13900 {
13901
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13902 {
13903 return qe_invalid;
13904 }
13905 }
13906
13907
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_width),f,keepdata))
13908 {
13909 return qe_invalid;
13910 }
13911
13912
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.s_height),f,keepdata))
13913 {
13914 return qe_invalid;
13915 }
13916
13917
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion >= 36 ) //expanded tiles
13918 {
13919
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13920 {
13921 return qe_invalid;
13922 }
13923 11264 }
13924 else
13925 {
13926
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13927 {
13928 return qe_invalid;
13929 }
13930 }
13931
13932
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_width),f,keepdata))
13933 {
13934 return qe_invalid;
13935 }
13936
13937
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.e_height),f,keepdata))
13938 {
13939 return qe_invalid;
13940 }
13941
13942
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hp),f,keepdata))
13943 {
13944 return qe_invalid;
13945 }
13946
13947
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.family),f,keepdata))
13948 {
13949 return qe_invalid;
13950 }
13951
13952
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
49152 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13953 {
13954 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13955 {
13956 tempguy.s_tile=tempguy.e_tile+120;
13957 tempguy.s_width=tempguy.e_width;
13958 tempguy.s_height=tempguy.e_height;
13959 }
13960 else tempguy.s_tile=860;
13961 }
13962
13963
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.cset),f,keepdata))
13964 {
13965 return qe_invalid;
13966 }
13967
13968
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.anim),f,keepdata))
13969 {
13970 return qe_invalid;
13971 }
13972
13973
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13974 {
13975 return qe_invalid;
13976 }
13977
13978
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.frate),f,keepdata))
13979 {
13980 return qe_invalid;
13981 }
13982
13983
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13984 {
13985 return qe_invalid;
13986 }
13987
13988
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 13) // April 2009
13989 {
13990 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13991 {
13992 tempguy.frate *= 2;
13993 tempguy.e_frate *= 2;
13994 }
13995 }
13996
13997
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 14) // May 1 2009
13998 {
13999 if(tempguy.anim==a2FRMSLOW)
14000 {
14001 tempguy.anim=a2FRM;
14002 tempguy.frate *= 2;
14003 }
14004
14005 if(tempguy.e_anim==a2FRMSLOW)
14006 {
14007 tempguy.e_anim=a2FRM;
14008 tempguy.e_frate *= 2;
14009 }
14010
14011 if(tempguy.anim==aFLIPSLOW)
14012 {
14013 tempguy.anim=aFLIP;
14014 tempguy.frate *= 2;
14015 }
14016
14017 if(tempguy.e_anim==aFLIPSLOW)
14018 {
14019 tempguy.e_anim=aFLIP;
14020 tempguy.e_frate *= 2;
14021 }
14022
14023 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14024
14025 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14026
14027 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14028 {
14029 tempguy.anim=a4FRM4DIR;
14030 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14031 }
14032
14033 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14034 {
14035 tempguy.e_anim=a4FRM4DIR;
14036 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14037 }
14038 }
14039
14040
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.dp),f,keepdata))
14041 {
14042 return qe_invalid;
14043 }
14044
14045 //correction for guy fire
14046
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 6)
14047 {
14048 if(i == gFIRE)
14049 tempguy.dp = 2;
14050 }
14051
14052
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14053 {
14054 return qe_invalid;
14055 }
14056
14057
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14058 {
14059 return qe_invalid;
14060 }
14061
14062 //correction for bosses using triple, "rising" fireballs
14063
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 5)
14064 {
14065 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14066 i == eGOHMA3 || i == eGOHMA4)
14067 {
14068 if(tempguy.weapon == ewFireball)
14069 tempguy.weapon = ewFireball2;
14070 }
14071 }
14072
14073
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.rate),f,keepdata))
14074 {
14075 return qe_invalid;
14076 }
14077
14078
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14079 {
14080 return qe_invalid;
14081 }
14082
14083
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.step),f,keepdata))
14084 {
14085 return qe_invalid;
14086 }
14087
14088 // HIGHLY UNORTHODOX UPDATING THING, part 2
14089
3/4
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 48640 times.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
49152 if(fixpolsvoice && tempguy.family==eePOLSV)
14090 {
14091 tempguy.step /= 2;
14092 }
14093
14094
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.homing),f,keepdata))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14110 {
14111
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14112 {
14113 return qe_invalid;
14114 }
14115
14116
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14117 {
14118 return qe_invalid;
14119 }
14120
14121
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14122 {
14123 return qe_invalid;
14124 }
14125
14126
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14127 {
14128 return qe_invalid;
14129 }
14130
14131
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14132 {
14133 return qe_invalid;
14134 }
14135
14136
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14137 {
14138 return qe_invalid;
14139 }
14140
14141
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14142 {
14143 return qe_invalid;
14144 }
14145
14146
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14147 {
14148 return qe_invalid;
14149 }
14150
14151
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14152 {
14153 return qe_invalid;
14154 }
14155
14156
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14157 {
14158 return qe_invalid;
14159 }
14160 49152 }
14161 else
14162 {
14163 int16_t tempMisc;
14164
14165 if(!p_igetw(&tempMisc,f,keepdata))
14166 {
14167 return qe_invalid;
14168 }
14169
14170 tempguy.misc1=tempMisc;
14171
14172 if(!p_igetw(&tempMisc,f,keepdata))
14173 {
14174 return qe_invalid;
14175 }
14176
14177 tempguy.misc2=tempMisc;
14178
14179 if(!p_igetw(&tempMisc,f,keepdata))
14180 {
14181 return qe_invalid;
14182 }
14183
14184 tempguy.misc3=tempMisc;
14185
14186 if(!p_igetw(&tempMisc,f,keepdata))
14187 {
14188 return qe_invalid;
14189 }
14190
14191 tempguy.misc4=tempMisc;
14192
14193 if(!p_igetw(&tempMisc,f,keepdata))
14194 {
14195 return qe_invalid;
14196 }
14197
14198 tempguy.misc5=tempMisc;
14199
14200 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14201 {
14202 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14203 tempguy.misc5 = 74;
14204 }
14205
14206 if(!p_igetw(&tempMisc,f,keepdata))
14207 {
14208 return qe_invalid;
14209 }
14210
14211 tempguy.misc6=tempMisc;
14212
14213 if(!p_igetw(&tempMisc,f,keepdata))
14214 {
14215 return qe_invalid;
14216 }
14217
14218 tempguy.misc7=tempMisc;
14219
14220 if(!p_igetw(&tempMisc,f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225 tempguy.misc8=tempMisc;
14226
14227 if(!p_igetw(&tempMisc,f,keepdata))
14228 {
14229 return qe_invalid;
14230 }
14231
14232 tempguy.misc9=tempMisc;
14233
14234 if(!p_igetw(&tempMisc,f,keepdata))
14235 {
14236 return qe_invalid;
14237 }
14238
14239 tempguy.misc10=tempMisc;
14240 }
14241
14242
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14243 {
14244 return qe_invalid;
14245 }
14246
14247
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14248 {
14249 return qe_invalid;
14250 }
14251
14252
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetw(&(tempguy.extend),f,keepdata))
14253 {
14254 return qe_invalid;
14255 }
14256
14257 //! Enemy Defences
14258
14259 //If a 2.50 quest, use only the 2.5 defences.
14260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14261 {
14262
2/2
✓ Branch 0 taken 933888 times.
✓ Branch 1 taken 49152 times.
983040 for(int32_t j=0; j<edefLAST; j++)
14263 {
14264
1/2
✓ Branch 0 taken 933888 times.
✗ Branch 1 not taken.
933888 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14265 {
14266 return qe_invalid;
14267 }
14268 933888 }
14269 //then copy the generic script defence to all the new script defences
14270
14271 49152 }
14272
14273
14274
14275
14276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(guyversion >= 18)
14277 {
14278
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14279 {
14280 return qe_invalid;
14281 }
14282
14283
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287 49152 }
14288
14289
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion >= 22)
14290 {
14291
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14292 {
14293 return qe_invalid;
14294 }
14295
14296
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14297 {
14298 return qe_invalid;
14299 }
14300 49152 }
14301 else if(guyversion >= 19)
14302 {
14303 int16_t tempMisc;
14304
14305 if(!p_igetw(&tempMisc,f,keepdata))
14306 {
14307 return qe_invalid;
14308 }
14309
14310 tempguy.misc11=tempMisc;
14311
14312 if(!p_igetw(&tempMisc,f,keepdata))
14313 {
14314 return qe_invalid;
14315 }
14316
14317 tempguy.misc12=tempMisc;
14318 }
14319
14320 //If a 2.54 or later quest, use all of the defences.
14321
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 24) // Add new guyversion conditional statement
14322 {
14323
2/2
✓ Branch 0 taken 247808 times.
✓ Branch 1 taken 11264 times.
259072 for(int32_t j=edefLAST; j<edefLAST255; j++)
14324 {
14325
1/2
✓ Branch 0 taken 247808 times.
✗ Branch 1 not taken.
247808 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14326 {
14327 return qe_invalid;
14328 }
14329 247808 }
14330 11264 }
14331
14332
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14333 {
14334
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14335 {
14336 378880 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14337 378880 }
14338 37888 }
14339
14340 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14341
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 25)
14342 {
14343
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14344 {
14345 return qe_invalid;
14346 }
14347
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14348 {
14349 return qe_invalid;
14350 }
14351
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14352 {
14353 return qe_invalid;
14354 }
14355
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14356 {
14357 return qe_invalid;
14358 }
14359
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14360 {
14361 return qe_invalid;
14362 }
14363 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14364
14365 */
14366 11264 }
14367 //More Enemy Editor vars for 2.60
14368
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 26)
14369 {
14370
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14371 {
14372 return qe_invalid;
14373 }
14374
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14375 {
14376 return qe_invalid;
14377 }
14378
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14379 {
14380 return qe_invalid;
14381 }
14382
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14383 {
14384 return qe_invalid;
14385 }
14386
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14387 {
14388 return qe_invalid;
14389 }
14390 11264 }
14391
14392
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14393 {
14394 37888 tempguy.wpnsprite = 0;
14395 37888 }
14396
14397
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 27)
14398 {
14399
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14400 {
14401 return qe_invalid;
14402 }
14403 11264 }
14404
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14405 {
14406 37888 tempguy.SIZEflags = 0;
14407 37888 }
14408
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion > 28)
14409 {
14410
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14411 {
14412 return qe_invalid;
14413 }
14414
14415 11264 }
14416
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14417 {
14418 37888 tempguy.frozentile = 0;
14419 37888 tempguy.frozencset = 0;
14420 37888 tempguy.frozenclock = 0;
14421
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14422 37888 }
14423
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 30)
14424 {
14425
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14426 {
14427 return qe_invalid;
14428 }
14429
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14430 {
14431 return qe_invalid;
14432 }
14433
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14434 {
14435 return qe_invalid;
14436 }
14437
2/2
✓ Branch 0 taken 112640 times.
✓ Branch 1 taken 11264 times.
123904 for ( int32_t q = 0; q < 10; q++ ) {
14438
1/2
✓ Branch 0 taken 112640 times.
✗ Branch 1 not taken.
112640 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14439 {
14440 return qe_invalid;
14441 }
14442 112640 }
14443
14444 11264 }
14445
14446
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 34)
14447 {
14448
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14449 {
14450 return qe_invalid;
14451 }
14452
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14453 {
14454 return qe_invalid;
14455 }
14456
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14457 {
14458 return qe_invalid;
14459 }
14460
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14461 {
14462 return qe_invalid;
14463 }
14464
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14465 {
14466 return qe_invalid;
14467 }
14468
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14469 {
14470 return qe_invalid;
14471 }
14472
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14473 {
14474 return qe_invalid;
14475 }
14476
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14477 {
14478 return qe_invalid;
14479 }
14480
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14481 {
14482 return qe_invalid;
14483 }
14484
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14485 {
14486 return qe_invalid;
14487 }
14488
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14489 {
14490 return qe_invalid;
14491 }
14492
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14493 {
14494 return qe_invalid;
14495 }
14496
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14497 {
14498 return qe_invalid;
14499 }
14500
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14505 {
14506 return qe_invalid;
14507 }
14508
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14509 {
14510 return qe_invalid;
14511 }
14512
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14513 {
14514 return qe_invalid;
14515 }
14516
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14517 {
14518 return qe_invalid;
14519 }
14520
14521
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14522
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14523 {
14524 return qe_invalid;
14525 }
14526 360448 }
14527
2/2
✓ Branch 0 taken 360448 times.
✓ Branch 1 taken 11264 times.
371712 for ( int32_t q = 0; q < 32; q++ ) {
14528
1/2
✓ Branch 0 taken 360448 times.
✗ Branch 1 not taken.
360448 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532 360448 }
14533
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.script),f,keepdata))
14534 {
14535 return qe_invalid;
14536 }
14537 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14538
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14539 {
14540
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14541 {
14542 return qe_invalid;
14543 }
14544 90112 }
14545
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 11264 times.
33792 for ( int32_t q = 0; q < 2; q++ )
14546 {
14547
1/2
✓ Branch 0 taken 22528 times.
✗ Branch 1 not taken.
22528 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14548 {
14549 return qe_invalid;
14550 }
14551 22528 }
14552
14553 11264 }
14554
14555
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 37)
14556 {
14557
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14558 {
14559 return qe_invalid;
14560 }
14561 11264 }
14562
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14563
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if(guyversion >= 38)
14564 {
14565
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14566 {
14567 return qe_invalid;
14568 }
14569
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14570 {
14571 return qe_invalid;
14572 }
14573
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14574 {
14575 return qe_invalid;
14576 }
14577
14578 11264 }
14579
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 38 )
14580 {
14581 37888 tempguy.misc13 = 0;
14582 37888 tempguy.misc14 = 0;
14583 37888 tempguy.misc15 = 0;
14584 37888 }
14585
14586
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 39 )
14587 {
14588
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14589 {
14590
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14591 {
14592
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14593 {
14594 return qe_invalid;
14595 }
14596 5857280 }
14597
2/2
✓ Branch 0 taken 5857280 times.
✓ Branch 1 taken 90112 times.
5947392 for ( int32_t w = 0; w < 65; w++ )
14598 {
14599
1/2
✓ Branch 0 taken 5857280 times.
✗ Branch 1 not taken.
5857280 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14600 {
14601 return qe_invalid;
14602 }
14603 5857280 }
14604 90112 }
14605
14606
14607 11264 }
14608
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 39 ) //apply old InitD strings to both
14609 {
14610
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ )
14611 {
14612 303104 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14613 303104 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14614 303104 }
14615 37888 }
14616
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 40 )
14617 {
14618
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14619 {
14620 return qe_invalid;
14621 }
14622 11264 }
14623
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if ( guyversion < 40 )
14624 {
14625 37888 tempguy.weaponscript = 0;
14626 37888 }
14627 //eweapon script InitD
14628
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
49152 if ( guyversion >= 41 )
14629 {
14630
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11264 times.
101376 for ( int32_t q = 0; q < 8; q++ )
14631 {
14632
1/2
✓ Branch 0 taken 90112 times.
✗ Branch 1 not taken.
90112 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14633 {
14634 return qe_invalid;
14635 }
14636 90112 }
14637
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if ( guy_cversion < 4 )
14638 {
14639 if ( tempguy.family == eeKEESE )
14640 {
14641
14642 if ( !tempguy.misc1 )
14643 {
14644 tempguy.misc16 = 120;
14645 tempguy.misc17 = 16;
14646
14647 }
14648 }
14649 if ( tempguy.family == eePEAHAT )
14650 {
14651 tempguy.misc16 = 80;
14652 tempguy.misc17 = 16;
14653 }
14654
14655 if ( tempguy.family == eeGHINI )
14656 {
14657 tempguy.misc16 = 120;
14658 tempguy.misc17 = 10;
14659 }
14660
14661 }
14662 11264 }
14663
14664
14665
14666 //default weapon sprites (quest version < 2.54)
14667 //port over old defaults -Z
14668
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 32)
14669 {
14670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.wpnsprite <= 0 )
14671 {
14672
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14673 {
14674 case wNone:
14675 31522 tempguy.wpnsprite = 0; break;
14676
14677 case wSword:
14678 case wBeam:
14679 case wBrang:
14680 case wBomb:
14681 case wSBomb:
14682 case wLitBomb:
14683 case wLitSBomb:
14684 case wArrow:
14685 case wFire:
14686 case wWhistle:
14687 case wBait:
14688 case wWand:
14689 case wMagic:
14690 case wCatching:
14691 case wWind:
14692 case wRefMagic:
14693 case wRefFireball:
14694 case wRefRock:
14695 case wHammer:
14696 case wHookshot:
14697 case wHSHandle:
14698 case wHSChain:
14699 case wSSparkle:
14700 case wFSparkle:
14701 case wSmack:
14702 case wPhantom:
14703 case wCByrna:
14704 case wRefBeam:
14705 case wStomp:
14706 case lwMax:
14707 case wScript1:
14708 case wScript2:
14709 case wScript3:
14710 case wScript4:
14711 case wScript5:
14712 case wScript6:
14713 case wScript7:
14714 case wScript8:
14715 case wScript9:
14716 case wScript10:
14717 case wIce:
14718 //Cannot use any of these weapons yet.
14719 tempguy.wpnsprite = -1;
14720 break;
14721
14722 case wEnemyWeapons:
14723 1257 case ewFireball: tempguy.wpnsprite = 17; break;
14724
14725 289 case ewArrow: tempguy.wpnsprite = 19; break;
14726 306 case ewBrang: tempguy.wpnsprite = 4; break;
14727 908 case ewSword: tempguy.wpnsprite = 20; break;
14728 472 case ewRock: tempguy.wpnsprite = 18; break;
14729 873 case ewMagic: tempguy.wpnsprite = 21; break;
14730 77 case ewBomb: tempguy.wpnsprite = 78; break;
14731 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14732 130 case ewLitBomb: tempguy.wpnsprite = 76; break;
14733 18 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14734 355 case ewFireTrail: tempguy.wpnsprite = 80; break;
14735 734 case ewFlame: tempguy.wpnsprite = 35; break;
14736 104 case ewWind: tempguy.wpnsprite = 36; break;
14737 74 case ewFlame2: tempguy.wpnsprite = 81; break;
14738 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14739 case ewIce: tempguy.wpnsprite = 83; break;
14740 751 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14741
14742
14743 default: break; //No assign.
14744 }
14745 37888 }
14746 37888 }
14747
14748 //default weapon fire sound (quest version < 2.54)
14749 //port over old defaults and zero new data. -Z
14750
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 34)
14751 {
14752
2/2
✓ Branch 0 taken 1212416 times.
✓ Branch 1 taken 37888 times.
1250304 for ( int32_t q = 0; q < 32; q++ )
14753 {
14754 1212416 tempguy.movement[q] = 0;
14755 1212416 tempguy.new_weapon[q] = 0;
14756
14757 1212416 }
14758
14759 //NPC Script attributes.
14760 37888 tempguy.script = 0; //No scripted enemies existed. -Z
14761
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14762
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 37888 times.
113664 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14763
14764 37888 tempguy.misc16 = 0;
14765 37888 tempguy.misc17 = 0;
14766 37888 tempguy.misc18 = 0;
14767 37888 tempguy.misc19 = 0;
14768 37888 tempguy.misc20 = 0;
14769 37888 tempguy.misc21 = 0;
14770 37888 tempguy.misc22 = 0;
14771 37888 tempguy.misc23 = 0;
14772 37888 tempguy.misc24 = 0;
14773 37888 tempguy.misc25 = 0;
14774 37888 tempguy.misc26 = 0;
14775 37888 tempguy.misc27 = 0;
14776 37888 tempguy.misc28 = 0;
14777 37888 tempguy.misc29 = 0;
14778 37888 tempguy.misc30 = 0;
14779 37888 tempguy.misc31 = 0;
14780 37888 tempguy.misc32 = 0;
14781
14782 //old default sounds
14783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.firesfx <= 0 )
14784 {
14785
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14786 {
14787 case wNone:
14788 31522 tempguy.firesfx = 0; break;
14789
14790 case wSword:
14791 case wBeam:
14792 case wBrang:
14793 case wBomb:
14794 case wSBomb:
14795 case wLitBomb:
14796 case wLitSBomb:
14797 case wArrow:
14798 case wFire:
14799 case wWhistle:
14800 case wBait:
14801 case wWand:
14802 case wMagic:
14803 case wCatching:
14804 case wWind:
14805 case wRefMagic:
14806 case wRefFireball:
14807 case wRefRock:
14808 case wHammer:
14809 case wHookshot:
14810 case wHSHandle:
14811 case wHSChain:
14812 case wSSparkle:
14813 case wFSparkle:
14814 case wSmack:
14815 case wPhantom:
14816 case wCByrna:
14817 case wRefBeam:
14818 case wStomp:
14819 case lwMax:
14820 case wScript1:
14821 case wScript2:
14822 case wScript3:
14823 case wScript4:
14824 case wScript5:
14825 case wScript6:
14826 case wScript7:
14827 case wScript8:
14828 case wScript9:
14829 case wScript10:
14830 case wIce:
14831 //Cannot use any of these weapons yet.
14832 tempguy.firesfx = -1;
14833 break;
14834
14835 case wEnemyWeapons:
14836 1257 case ewFireball: tempguy.firesfx = 40; break;
14837
14838 289 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14839 306 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14840 908 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14841 472 case ewRock: tempguy.firesfx = 51; break;
14842 873 case ewMagic: tempguy.firesfx = 32; break;
14843 77 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14844 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14845 130 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14846 18 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14847 355 case ewFireTrail: tempguy.firesfx = 13; break;
14848 734 case ewFlame: tempguy.firesfx = 13; break;
14849 104 case ewWind: tempguy.firesfx = 32; break;
14850 74 case ewFlame2: tempguy.firesfx = 13; break;
14851 case ewFlame2Trail: tempguy.firesfx = 13; break;
14852 case ewIce: tempguy.firesfx = 44; break;
14853 751 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14854
14855 //what about special attacks (e.g. summoning == 56)
14856 default: break; //No assign.
14857 }
14858 37888 }
14859 37888 }
14860
14861 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14862
4/6
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
✓ Branch 2 taken 11264 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11264 times.
49152 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14863 {
14864
2/2
✓ Branch 0 taken 2994 times.
✓ Branch 1 taken 34894 times.
37888 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14865 37888 }
14866 //Keese and bat halt rates.
14867
3/4
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37888 times.
49152 if ( guyversion < 42 && guy_cversion < 4 )
14868 {
14869
14870
2/2
✓ Branch 0 taken 37378 times.
✓ Branch 1 taken 510 times.
37888 if ( tempguy.family == eeKEESE )
14871 {
14872
14873
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 314 times.
510 if ( !tempguy.misc1 )
14874 {
14875 314 tempguy.misc16 = 120;
14876 314 tempguy.misc17 = 16;
14877
14878 314 }
14879 510 }
14880
2/2
✓ Branch 0 taken 37726 times.
✓ Branch 1 taken 162 times.
37888 if ( tempguy.family == eePEAHAT )
14881 {
14882 162 tempguy.misc16 = 80;
14883 162 tempguy.misc17 = 16;
14884 162 }
14885
2/2
✓ Branch 0 taken 37814 times.
✓ Branch 1 taken 74 times.
37888 if ( tempguy.family == eeGHINI )
14886 {
14887 74 tempguy.misc16 = 120;
14888 74 tempguy.misc17 = 10;
14889 74 }
14890
14891
14892 37888 }
14893
14894
14895 //miscellaneous other corrections
14896 //fix the mirror wizzrobe -DD
14897
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 7)
14898 {
14899 if(i == eMWIZ)
14900 {
14901 tempguy.misc2 = 0;
14902 tempguy.misc4 = 1;
14903 }
14904 }
14905
14906
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 8)
14907 {
14908 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14909 {
14910 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14911 tempguy.misc5 = 4; //neck length in segments
14912 tempguy.misc6 = 8; //neck offset from first body tile
14913 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14914 tempguy.misc8 = 168; //head offset from first body tile
14915 tempguy.misc9 = 228; //flying head offset from first body tile
14916
14917 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14918 {
14919 tempguy.misc6 += 10; //neck offset from first body tile
14920 tempguy.misc8 -= 12; //head offset from first body tile
14921 }
14922 }
14923 }
14924
14925
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14926 {
14927 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14928 tempguy.bosspal = spDIG;
14929 }
14930
14931
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 11) // December 2007 - Spinning Tile fix
14932 {
14933 if(tempguy.family==eeSPINTILE)
14934 {
14935 tempguy.flags |= guy_superman;
14936 tempguy.item_set = 0; // Don't drop items
14937 tempguy.step = 300;
14938 }
14939 }
14940
14941
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14942 {
14943 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14944 {
14945 if(tempguy.family==eeROPE)
14946 {
14947 tempguy.flags2 &= ~guy_flashing;
14948 }
14949 }
14950
14951 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14952 {
14953 if(tempguy.family==eeBUBBLE)
14954 {
14955 tempguy.flags2 &= ~guy_flashing;
14956 }
14957 }
14958
14959 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14960 {
14961 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14962 {
14963 tempguy.flags2 |= guy_blinking;
14964 }
14965
14966 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14967 {
14968 tempguy.flags2 |= guy_transparent;
14969 }
14970 }
14971 }
14972
14973
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14974 {
14975 if(i==gFIRE)
14976 {
14977 tempguy.e_anim = aFLIP;
14978 tempguy.e_frate = 24;
14979 }
14980
14981 if(i==gFAIRY)
14982 {
14983 tempguy.e_anim = a2FRM;
14984 tempguy.e_frate = 16;
14985 }
14986 }
14987
14988
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14989 {
14990 if(i==0) Z_message("Updating guys to version 16...\n");
14991
14992 update_guy_1(&tempguy);
14993
14994 if(i==eMPOLSV)
14995 {
14996 tempguy.defense[edefARROW] = edCHINK;
14997 tempguy.defense[edefMAGIC] = ed1HKO;
14998 tempguy.defense[edefREFMAGIC] = ed1HKO;
14999 }
15000 }
15001
15002
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 17) // December 2009
15003 {
15004 if(tempguy.family==eePROJECTILE)
15005 {
15006 tempguy.misc1 = 0;
15007 }
15008 }
15009
15010
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 18) // January 2010
15011 {
15012 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15013 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15014
15015 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15016 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15017
15018 if(tempguy.family == eeAQUA)
15019 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15020 else if(tempguy.family == eeMANHAN)
15021 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15022 else if(tempguy.family==eePATRA)
15023 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15024 else if(tempguy.family==eeGHOMA)
15025 {
15026 for(int32_t j=0; j<edefLAST; j++)
15027 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15028
15029 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15030
15031 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15032
15033 tempguy.misc1--;
15034 }
15035 else if(tempguy.family == eeGLEEOK)
15036 {
15037 for(int32_t j=0; j<edefLAST; j++)
15038 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15039
15040 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15041 }
15042 else if(tempguy.family == eeARMOS)
15043 {
15044 tempguy.family=eeWALK;
15045 tempguy.hrate = 0;
15046 tempguy.misc10 = tempguy.misc1;
15047 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15048 tempguy.misc9 = e9tARMOS;
15049 }
15050 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15051 {
15052 tempguy.family=eeWALK;
15053 tempguy.hrate = 0;
15054 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15055 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15056 }
15057
15058 // Spawn animation flags
15059 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15060 tempguy.flags |= guy_fadeflicker;
15061 else
15062 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15063 }
15064
15065
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 20) // April 2010
15066 {
15067 if(tempguy.family == eeTRAP)
15068 {
15069 tempguy.misc2 = tempguy.misc10;
15070
15071 if(tempguy.misc10>=1)
15072 {
15073 tempguy.misc1++;
15074 }
15075
15076 tempguy.misc10 = 0;
15077 }
15078
15079 // Bomb Blast fix
15080 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15081 tempguy.weapon = ewLitBomb;
15082 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15083 tempguy.weapon = ewLitSBomb;
15084 }
15085
15086
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 21) // September 2011
15087 {
15088 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15089 {
15090 if(tempguy.family == eeKEESETRIB)
15091 {
15092 tempguy.family = eeKEESE;
15093 tempguy.misc2 = e2tKEESETRIB;
15094 tempguy.misc1 = 0;
15095 }
15096
15097 tempguy.rate = 2;
15098 tempguy.hrate = 8;
15099 tempguy.homing = 0;
15100 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15101 }
15102 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15103 {
15104 if(tempguy.family == eePEAHAT)
15105 {
15106 tempguy.rate = 4;
15107 tempguy.step = 62;
15108 }
15109 else
15110 tempguy.step = 25;
15111
15112 tempguy.hrate = 8;
15113 tempguy.homing = 0;
15114 }
15115 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15116 {
15117 if(tempguy.family == eeMANHAN)
15118 tempguy.step=50;
15119
15120 tempguy.hrate = 16;
15121 tempguy.homing = 0;
15122 }
15123 else if(tempguy.family == eeGLEEOK)
15124 {
15125 tempguy.rate = 2;
15126 tempguy.homing = 0;
15127 tempguy.hrate = 9;
15128 tempguy.step=89;
15129 }
15130 else if(tempguy.family == eeGHINI)
15131 {
15132 tempguy.rate = 4;
15133 tempguy.hrate = 12;
15134 tempguy.step=62;
15135 tempguy.homing = 0;
15136 }
15137
15138 // Bigdig random rate fix
15139 if(tempguy.family==eeDIG && tempguy.misc10==1)
15140 {
15141 tempguy.rate = 2;
15142 }
15143 }
15144
15145
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if(guyversion < 24) // November 2012
15146 {
15147 if(tempguy.family==eeLANM)
15148 tempguy.misc3 = 1;
15149 else if(tempguy.family==eeMOLD)
15150 tempguy.misc2 = 0;
15151 }
15152
15153
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15154 {
15155
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 37241 times.
37888 if(tempguy.family!=eeDIG)
15156 {
15157 37241 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15158 37241 }
15159
15160 37888 }
15161 // does not seem to solve the issue!
15162
1/2
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
49152 if ( Header->zelda_version <= 0x210 )
15163 {
15164 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15165 if ( tempguy.family == eeDONGO )
15166 {
15167 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15168 }
15169 }
15170
15171
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion >= 42)
15172 {
15173
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 1024 times.
11264 if(guyversion >= 47)
15174 {
15175
1/2
✓ Branch 0 taken 10240 times.
✗ Branch 1 not taken.
10240 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15176 {
15177 return qe_invalid;
15178 }
15179 10240 }
15180 else
15181 {
15182 byte fl;
15183
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15184 {
15185 return qe_invalid;
15186 }
15187 1024 tempguy.moveflags = fl;
15188 }
15189 11264 }
15190 else
15191 {
15192
7/8
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 29895 times.
✓ Branch 2 taken 1177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 234 times.
✓ Branch 7 taken 5662 times.
37888 switch(tempguy.family)
15193 {
15194 //No gravity; floats over pits
15195 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15196 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15197 //Special (bosses, etc)
15198 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15199 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15200 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15201 29895 tempguy.moveflags = FLAG_CAN_PITWALK;
15202 29895 break;
15203 //No gravity, but falls in pits
15204 case eeLEV:
15205 507 tempguy.moveflags = FLAG_CAN_PITFALL;
15206 507 break;
15207 //Bosses that respect pits
15208 case eeDONGO:
15209 271 tempguy.moveflags = FLAG_OBEYS_GRAV;
15210 271 break;
15211 case eeLANM:
15212 234 tempguy.moveflags = 0;
15213 234 break;
15214 //Gravity, floats over pits
15215 case eeWIZZ: case eeWALLM: case eeGHINI:
15216 1177 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15217 1177 break;
15218 //Gravity and falls in pits
15219 case eeWALK:
15220
4/4
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 5074 times.
5662 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15221 588 break;
15222 [[fallthrough]];
15223 case eeOTHER:
15224 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15225 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15226 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15227 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15228 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15229 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15230 5216 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15231 5216 }
15232 }
15233
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 43)
15234 {
15235
2/2
✓ Branch 0 taken 31072 times.
✓ Branch 1 taken 6816 times.
37888 switch(tempguy.family)
15236 {
15237 //No gravity; floats over pits
15238 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15239 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15240 //Special (bosses, etc)
15241 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15242 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15243 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15244 case eeWIZZ: case eeWALLM: case eeGHINI:
15245 //Gravity, floats over pits
15246 31072 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15247 31072 break;
15248 }
15249 37888 }
15250
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion < 44)
15251 {
15252
2/2
✓ Branch 0 taken 37527 times.
✓ Branch 1 taken 361 times.
37888 if ( tempguy.family == eeGHOMA )
15253 {
15254 361 tempguy.flags |= guy_fadeinstant;
15255 361 }
15256 37888 }
15257
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if (guyversion > 44)
15258 {
15259
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15260 {
15261 return qe_invalid;
15262 }
15263
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15264 {
15265 return qe_invalid;
15266 }
15267
1/2
✓ Branch 0 taken 11264 times.
✗ Branch 1 not taken.
11264 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15268 {
15269 return qe_invalid;
15270 }
15271 11264 }
15272 else
15273 {
15274
2/2
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 148 times.
37888 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15275 37888 tempguy.spr_death = iwDeath;
15276 37888 tempguy.spr_spawn = iwSpawn;
15277 }
15278
15279
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 37888 times.
49152 if(guyversion < 46)
15280 {
15281
4/4
✓ Branch 0 taken 5662 times.
✓ Branch 1 taken 32226 times.
✓ Branch 2 taken 5349 times.
✓ Branch 3 taken 313 times.
37888 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15282 {
15283 313 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15284 313 }
15285 37888 }
15286
15287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49152 times.
49152 if(keepdata)
15288 {
15289 49152 guysbuf[i] = tempguy;
15290 49152 }
15291 49152 }
15292 96 }
15293
15294 96 return 0;
15295 99 }
15296
15297 void update_guy_1(guydata *tempguy) // November 2009
15298 {
15299 bool doesntcount = false;
15300 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15301
15302 switch(tempguy->family)
15303 {
15304 case 1: //eeWALK
15305 switch(tempguy->misc10)
15306 {
15307 case 0: //Stalfos
15308 if(tempguy->misc1==1) // Fires four projectiles at once
15309 tempguy->misc1=4;
15310
15311 break;
15312
15313 case 1: //Darknut
15314 goto darknuts;
15315 break;
15316 }
15317
15318 tempguy->misc10 = 0;
15319 break;
15320
15321 case 2: //eeSHOOT
15322 tempguy->family = eeWALK;
15323
15324 switch(tempguy->misc10)
15325 {
15326 case 0: //Octorok
15327 if(tempguy->misc1==1||tempguy->misc1==2)
15328 {
15329 tempguy->misc1=e1tFIREOCTO;
15330 tempguy->misc2=e2tFIREOCTO;
15331 }
15332 else tempguy->misc1 = 0;
15333
15334 tempguy->misc6=tempguy->misc4;
15335 tempguy->misc4=tempguy->misc3;
15336 tempguy->misc3=0;
15337 break;
15338
15339 case 1: // Moblin
15340 tempguy->misc1 = 0;
15341 break;
15342
15343 case 2: //Lynel
15344 tempguy->misc6=tempguy->misc1+1;
15345 tempguy->misc1=0;
15346 break;
15347
15348 case 3: //Stalfos 2
15349 if(tempguy->misc1==1) // Fires four projectiles at once
15350 tempguy->misc1=e1t4SHOTS;
15351 else tempguy->misc1 = 0;
15352
15353 break;
15354
15355 case 4: //Darknut 5
15356 darknuts:
15357 tempguy->defense[edefFIRE] = edIGNORE;
15358 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15359 tempguy->defense[edefHOOKSHOT] = 0;
15360 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15361 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15362
15363 if(tempguy->misc1==1)
15364 tempguy->misc1=2;
15365 else if(tempguy->misc1==2)
15366 {
15367 tempguy->misc4=tempguy->misc3;
15368 tempguy->misc3=tempguy->misc2;
15369 tempguy->misc2=e2tSPLIT;
15370 tempguy->misc1 = 0;
15371 }
15372 else tempguy->misc1 = 0;
15373
15374 tempguy->flags |= inv_front;
15375
15376 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15377 tempguy->flags |= guy_bkshield;
15378
15379 break;
15380 }
15381
15382 tempguy->misc10 = 0;
15383 break;
15384
15385 /*
15386 case 9: //eeARMOS
15387 tempguy->family = eeWALK;
15388 break;
15389 */
15390 case 11: //eeGEL
15391 case 33: //eeGELTRIB
15392 if(tempguy->family==33)
15393 {
15394 tempguy->misc4 = 1;
15395
15396 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15397 tempguy->misc3 = tempguy->misc2;
15398
15399 tempguy->misc2 = e2tTRIBBLE;
15400 }
15401 else
15402 {
15403 tempguy->misc4 = 0;
15404 tempguy->misc3 = 0;
15405 tempguy->misc2 = 0;
15406 }
15407
15408 tempguy->family = eeWALK;
15409
15410 if(tempguy->misc1)
15411 {
15412 tempguy->misc1=1;
15413 tempguy->weapon = ewFireTrail;
15414 }
15415
15416 break;
15417
15418 case 34: //eeZOLTRIB
15419 case 12: //eeZOL
15420 tempguy->misc4=tempguy->misc3;
15421 tempguy->misc3=tempguy->misc2;
15422 tempguy->family = eeWALK;
15423 tempguy->misc2=e2tSPLITHIT;
15424
15425 if(tempguy->misc1)
15426 {
15427 tempguy->misc1=1;
15428 tempguy->weapon = ewFireTrail;
15429 }
15430
15431 break;
15432
15433 case 13: //eeROPE
15434 tempguy->family = eeWALK;
15435 tempguy->misc9 = e9tROPE;
15436
15437 if(tempguy->misc1)
15438 {
15439 tempguy->misc4 = tempguy->misc3;
15440 tempguy->misc3 = tempguy->misc2;
15441 tempguy->misc2 = e2tBOMBCHU;
15442 }
15443
15444 tempguy->misc1 = 0;
15445 break;
15446
15447 case 14: //eeGORIYA
15448 tempguy->family = eeWALK;
15449
15450 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15451
15452 break;
15453
15454 case 17: //eeBUBBLE
15455 tempguy->family = eeWALK;
15456 tempguy->misc8 = tempguy->misc2;
15457 tempguy->misc7 = tempguy->misc1 + 1;
15458 tempguy->misc1 = tempguy->misc2 = 0;
15459
15460 //fallthrogh
15461 case eeTRAP:
15462 case eeROCK:
15463 doesntcount = true;
15464 break;
15465
15466 case 35: //eeVIRETRIB
15467 case 18: //eeVIRE
15468 tempguy->family = eeWALK;
15469 tempguy->misc4=tempguy->misc3;
15470 tempguy->misc3=tempguy->misc2;
15471 tempguy->misc2=e2tSPLITHIT;
15472 tempguy->misc9=e9tVIRE;
15473 break;
15474
15475 case 19: //eeLIKE
15476 tempguy->family = eeWALK;
15477 tempguy->misc7 = e7tEATITEMS;
15478 tempguy->misc8=95;
15479 break;
15480
15481 case 20: //eePOLSV
15482 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15483 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15484 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15485 tempguy->defense[edefARROW] = ed1HKO;
15486 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15487 tempguy->family = eeWALK;
15488 tempguy->misc9 = e9tPOLSVOICE;
15489 tempguy->rate = 4;
15490 tempguy->homing = 32;
15491 tempguy->hrate = 10;
15492 tempguy->grumble = 0;
15493 break;
15494
15495 case eeWIZZ:
15496 if(tempguy->misc4)
15497 {
15498 for(int32_t i=0; i < edefLAST; i++)
15499 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15500 }
15501 else
15502 {
15503 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15504 tempguy->defense[edefMAGIC] = edCHINK;
15505 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15506 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15507 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15508 }
15509
15510 break;
15511
15512 case eePEAHAT:
15513 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15514
15515 if(!(tempguy->flags & guy_bhit))
15516 tempguy->defense[edefBRANG] = edSTUNONLY;
15517
15518 break;
15519
15520 case eeLEV:
15521 tempguy->defense[edefSTOMP] = edCHINK;
15522 break;
15523 }
15524
15525 // Old flags
15526 if(tempguy->flags & guy_superman)
15527 {
15528 for(int32_t i = 0; i < edefLAST; i++)
15529 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15530 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15531 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15532 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15533 }
15534
15535 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15536
15537 if(doesntcount)
15538 tempguy->flags |= (guy_doesntcount);
15539 }
15540
15541
15542 144976 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15543 {
15544 byte tempbyte, padding;
15545 int32_t extras, secretcombos;
15546 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->valid),f,true))
15548 {
15549 return qe_invalid;
15550 }
15551
15552
15553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->guy),f,true))
15554 {
15555 return qe_invalid;
15556 }
15557
15558
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15559 {
15560 if(!p_getc(&tempbyte,f,true))
15561 {
15562 return qe_invalid;
15563 }
15564
15565 temp_mapscr->str=tempbyte;
15566 }
15567 else
15568 {
15569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->str),f,true))
15570 {
15571 return qe_invalid;
15572 }
15573 }
15574
15575
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->room),f,true))
15576 {
15577 return qe_invalid;
15578 }
15579
15580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->item),f,true))
15581 {
15582 return qe_invalid;
15583 }
15584
15585
3/6
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133960 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15586 {
15587 11016 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15588 11016 }
15589 else
15590 {
15591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15592 return qe_invalid;
15593 }
15594
15595
1/4
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version < 0x192)||
15596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15597 {
15598 if(!p_getc(&tempbyte,f,true))
15599 {
15600 return qe_invalid;
15601 }
15602 }
15603
15604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15605 {
15606 return qe_invalid;
15607 }
15608
15609
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15610 {
15611 if(!p_getc(&tempbyte,f,true))
15612 {
15613 return qe_invalid;
15614 }
15615 }
15616
15617
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15618 {
15619
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15620 {
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15622 {
15623 return qe_invalid;
15624 }
15625 401880 }
15626 133960 }
15627 else
15628 {
15629 11016 temp_mapscr->tilewarptype[1]=0;
15630 11016 temp_mapscr->tilewarptype[2]=0;
15631 11016 temp_mapscr->tilewarptype[3]=0;
15632 }
15633
15634
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15635 {
15636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15637 {
15638 return qe_invalid;
15639 }
15640 144976 }
15641
15642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15643 {
15644 return qe_invalid;
15645 }
15646
15647 144976 temp_mapscr->warpreturnx[1]=0;
15648 144976 temp_mapscr->warpreturnx[2]=0;
15649 144976 temp_mapscr->warpreturnx[3]=0;
15650
15651
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15652 {
15653
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15654 {
15655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15656 {
15657 return qe_invalid;
15658 }
15659 401880 }
15660 133960 }
15661
15662
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15663 {
15664 return qe_invalid;
15665 }
15666
15667 144976 temp_mapscr->warpreturny[1]=0;
15668 144976 temp_mapscr->warpreturny[2]=0;
15669 144976 temp_mapscr->warpreturny[3]=0;
15670
15671
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15672 {
15673
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15674 {
15675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15676 {
15677 return qe_invalid;
15678 }
15679 401880 }
15680
15681
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(version>=18)
15682 {
15683
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15684 {
15685 return qe_invalid;
15686 }
15687 133960 }
15688 else
15689 {
15690 byte temp;
15691
15692 if(!p_getc(&temp,f,true))
15693 {
15694 return qe_invalid;
15695 }
15696
15697 temp_mapscr->warpreturnc=temp<<8|temp;
15698 }
15699 133960 }
15700
15701
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->stairx),f,true))
15702
15703 {
15704 return qe_invalid;
15705 }
15706
15707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->stairy),f,true))
15708 {
15709 return qe_invalid;
15710 }
15711
15712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemx),f,true))
15713 {
15714 return qe_invalid;
15715 }
15716
15717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->itemy),f,true))
15718 {
15719 return qe_invalid;
15720 }
15721
15722
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version > 15) // February 2009
15723 {
15724
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->color),f,true))
15725 {
15726 return qe_invalid;
15727 }
15728 133960 }
15729 else
15730 {
15731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(!p_getc(& tempbyte,f,true))
15732 {
15733 return qe_invalid;
15734 }
15735
15736 11016 temp_mapscr->color = (word) tempbyte;
15737 }
15738
15739
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15740 {
15741 return qe_invalid;
15742 }
15743
15744
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15745 {
15746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15747 {
15748 return qe_invalid;
15749
15750 }
15751 579904 }
15752
15753
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
15754 {
15755
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
15756 {
15757 return qe_invalid;
15758 }
15759
15760 11016 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15761
15762
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15763 {
15764 for(int32_t i=1; i<4; i++)
15765 {
15766 if(!p_getc(&(tempbyte),f,true))
15767 {
15768 return qe_invalid;
15769 }
15770
15771 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15772 }
15773 }
15774 else
15775 {
15776 11016 temp_mapscr->tilewarpdmap[1]=0;
15777 11016 temp_mapscr->tilewarpdmap[2]=0;
15778 11016 temp_mapscr->tilewarpdmap[3]=0;
15779 }
15780 11016 }
15781 else
15782 {
15783
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
15784 {
15785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15786 {
15787 return qe_invalid;
15788 }
15789 535840 }
15790 }
15791
15792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15793 {
15794 return qe_invalid;
15795 }
15796
15797
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15798 {
15799
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15800 {
15801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15802 {
15803 return qe_invalid;
15804 }
15805 401880 }
15806 133960 }
15807 else
15808 {
15809 11016 temp_mapscr->tilewarpscr[1]=0;
15810 11016 temp_mapscr->tilewarpscr[2]=0;
15811 11016 temp_mapscr->tilewarpscr[3]=0;
15812 }
15813
15814
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15815 {
15816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15817 {
15818 return qe_invalid;
15819 }
15820 133960 }
15821 else
15822 {
15823 11016 temp_mapscr->tilewarpoverlayflags=0;
15824 }
15825
15826
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15827 {
15828 return qe_invalid;
15829 }
15830
15831
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
15832 {
15833 if(!p_getc(&tempbyte,f,true))
15834 {
15835 return qe_invalid;
15836 }
15837
15838 }
15839
15840
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15841 {
15842 if(!p_getc(&padding,f,true))
15843 {
15844 return qe_invalid;
15845 }
15846 }
15847
15848
2/2
✓ Branch 0 taken 1449760 times.
✓ Branch 1 taken 144976 times.
1594736 for(int32_t k=0; k<10; k++)
15849 {
15850 /*
15851 if (!temp_mapscr->enemy[k])
15852 {
15853 continue;
15854 }
15855 */
15856
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15857 {
15858 if(!p_getc(&tempbyte,f,true))
15859 {
15860 return qe_invalid;
15861 }
15862
15863 temp_mapscr->enemy[k]=tempbyte;
15864 }
15865 else
15866 {
15867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1449760 times.
1449760 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15868 {
15869 return qe_invalid;
15870 }
15871 }
15872
15873
2/6
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1449760 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1449760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15874 {
15875 //using enumerations here is dangerous
15876 //very easy to break old quests -DD
15877 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15878 {
15879 temp_mapscr->enemy[k]+=5;
15880 }
15881 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15882 {
15883 temp_mapscr->enemy[k]+=1;
15884 }
15885 }
15886
15887
2/2
✓ Branch 0 taken 1339600 times.
✓ Branch 1 taken 110160 times.
1449760 if(version < 9)
15888 {
15889
2/2
✓ Branch 0 taken 102675 times.
✓ Branch 1 taken 7485 times.
110160 if(temp_mapscr->enemy[k]>0)
15890 {
15891 7485 temp_mapscr->enemy[k]+=10;
15892 7485 }
15893 110160 }
15894 //don't read in any invalid data
15895
1/2
✓ Branch 0 taken 1449760 times.
✗ Branch 1 not taken.
1449760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15896 {
15897 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15898 temp_mapscr->enemy[k] = 0;
15899 }
15900 1449760 }
15901
15902
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->pattern),f,true))
15903 {
15904 return qe_invalid;
15905 }
15906
15907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15908 {
15909 return qe_invalid;
15910 }
15911
15912
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15913 {
15914
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15915 {
15916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15917 {
15918 return qe_invalid;
15919 }
15920 401880 }
15921 133960 }
15922 else
15923 {
15924 11016 temp_mapscr->sidewarptype[1]=0;
15925 11016 temp_mapscr->sidewarptype[2]=0;
15926 11016 temp_mapscr->sidewarptype[3]=0;
15927 }
15928
15929
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version >= 15)
15930 {
15931
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15932 {
15933 return qe_invalid;
15934 }
15935 133960 }
15936 else
15937 {
15938 11016 temp_mapscr->sidewarpoverlayflags=0;
15939 }
15940
15941
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15947 {
15948 return qe_invalid;
15949 }
15950
15951
2/2
✓ Branch 0 taken 579904 times.
✓ Branch 1 taken 144976 times.
724880 for(int32_t k=0; k<4; k++)
15952 {
15953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579904 times.
579904 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15954 {
15955 return qe_invalid;
15956 }
15957 579904 }
15958
15959
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15960 {
15961 return qe_invalid;
15962 }
15963
15964
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15965 {
15966
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 401880 times.
535840 for(int32_t i=1; i<4; i++)
15967 {
15968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15969 {
15970 return qe_invalid;
15971 }
15972 401880 }
15973 133960 }
15974 else
15975 {
15976 11016 temp_mapscr->sidewarpscr[1]=0;
15977 11016 temp_mapscr->sidewarpscr[2]=0;
15978 11016 temp_mapscr->sidewarpscr[3]=0;
15979 }
15980
15981
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version <= 11)
15982 {
15983
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!p_getc(&(tempbyte),f,true))
15984 {
15985 return qe_invalid;
15986 }
15987
15988 11016 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15989
15990
2/6
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11016 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15991 {
15992 for(int32_t i=1; i<4; i++)
15993 {
15994 if(!p_getc(&(tempbyte),f,true))
15995 {
15996 return qe_invalid;
15997 }
15998
15999 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16000 }
16001 }
16002 else
16003 {
16004 11016 temp_mapscr->sidewarpdmap[1]=0;
16005 11016 temp_mapscr->sidewarpdmap[2]=0;
16006 11016 temp_mapscr->sidewarpdmap[3]=0;
16007 }
16008 11016 }
16009 else
16010 {
16011
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
16012 {
16013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16014 {
16015 return qe_invalid;
16016 }
16017 535840 }
16018 }
16019
16020
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16021 {
16022
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16023 {
16024 return qe_invalid;
16025 }
16026 133960 }
16027 11016 else temp_mapscr->sidewarpindex = 0;
16028
16029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16030 {
16031 return qe_invalid;
16032 }
16033
16034
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(Header->zelda_version < 0x193)
16035 {
16036 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16037 {
16038 return qe_invalid;
16039 }
16040 }
16041
16042
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16043 {
16044 return qe_invalid;
16045 }
16046
16047
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16048 {
16049 return qe_invalid;
16050 }
16051
16052
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_getc(&(temp_mapscr->flags),f,true))
16053 {
16054 return qe_invalid;
16055 }
16056
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags2),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 if(!p_getc(&(temp_mapscr->flags3),f,true))
16063 {
16064 return qe_invalid;
16065 }
16066
16067
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16068 //if (version>2)
16069 {
16070
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags4),f,true))
16071 {
16072 return qe_invalid;
16073 }
16074 133960 }
16075
16076
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16077 {
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags5),f,true))
16079 {
16080 return qe_invalid;
16081 }
16082
16083
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16084 {
16085 return qe_invalid;
16086 }
16087
16088
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16089 {
16090 return qe_invalid;
16091 }
16092
16093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(temp_mapscr->flags5&32)
16094 {
16095 temp_mapscr->flags5 &= ~32;
16096 temp_mapscr->noreset |= 48;
16097 }
16098
16099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(version<8)
16100 {
16101 if(temp_mapscr->noreset&1)
16102 {
16103 temp_mapscr->noreset|=8192;
16104 }
16105
16106 if(temp_mapscr->nocarry&1)
16107 {
16108 temp_mapscr->nocarry|=8192;
16109 temp_mapscr->nocarry&=~1;
16110 }
16111 }
16112 133960 }
16113 else
16114 {
16115 11016 temp_mapscr->flags5 = 0;
16116 11016 temp_mapscr->noreset = 0;
16117 11016 temp_mapscr->nocarry = 0;
16118 }
16119
16120
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16121 {
16122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags6),f,true))
16123 {
16124 return qe_invalid;
16125 }
16126 133960 }
16127
16128
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>5)
16129 {
16130
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags7),f,true))
16131 {
16132 return qe_invalid;
16133 }
16134
16135
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags8),f,true))
16136 {
16137 return qe_invalid;
16138 }
16139
16140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags9),f,true))
16141 {
16142 return qe_invalid;
16143 }
16144
16145
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags10),f,true))
16146 {
16147 return qe_invalid;
16148 }
16149
16150
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16151 {
16152 return qe_invalid;
16153 }
16154 133960 }
16155 else
16156 {
16157 11016 temp_mapscr->csensitive=1;
16158 }
16159
16160
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<14) // August 2007: screen SFX added
16161 {
16162
2/2
✓ Branch 0 taken 10962 times.
✓ Branch 1 taken 54 times.
11016 if(temp_mapscr->flags&8) //fROAR
16163 {
16164 54 temp_mapscr->bosssfx=
16165
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 45 times.
54 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16166 45 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16167 WAV_ROAR;
16168 54 }
16169
16170
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 10941 times.
11016 if(temp_mapscr->flags&128) //fSEA
16171 {
16172 75 temp_mapscr->oceansfx=WAV_SEA;
16173 75 }
16174
16175
1/2
✓ Branch 0 taken 11016 times.
✗ Branch 1 not taken.
11016 if(!(temp_mapscr->flags3&64)) //fNOSECRETSOUND
16176 {
16177 11016 temp_mapscr->secretsfx=WAV_SECRET;
16178 11016 }
16179
16180 11016 temp_mapscr->flags3 &= ~66; //64|2
16181 11016 temp_mapscr->flags2 &= ~32;
16182 11016 temp_mapscr->flags &= ~136; // 128|8
16183 11016 }
16184 else
16185 {
16186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16187 {
16188 return qe_invalid;
16189 }
16190
16191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16192 {
16193 return qe_invalid;
16194 }
16195
16196
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16197 {
16198 return qe_invalid;
16199 }
16200 }
16201
16202
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version<15) // October 2007: another SFX
16203 {
16204 11016 temp_mapscr->holdupsfx=WAV_PICKUP;
16205 11016 }
16206 else
16207 {
16208
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16209 {
16210 return qe_invalid;
16211 }
16212 }
16213
16214
16215
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16216 {
16217
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16218 {
16219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16220 {
16221 return qe_invalid;
16222 }
16223 869856 }
16224
16225
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 869856 times.
1014832 for(int32_t k=0; k<6; k++)
16226 {
16227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16228 {
16229 return qe_invalid;
16230 }
16231 869856 }
16232 144976 }
16233 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16234 {
16235 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16236 {
16237 return qe_invalid;
16238 }
16239
16240 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16241 {
16242 return qe_invalid;
16243 }
16244
16245 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16246 {
16247 return qe_invalid;
16248 }
16249
16250 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16251
16252 {
16253 return qe_invalid;
16254 }
16255 }
16256
16257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16258 {
16259 for(int32_t k=0; k<6; k++)
16260 {
16261 if(!p_getc(&tempbyte,f,true)) //layerxsize
16262 {
16263 return qe_invalid;
16264 }
16265 }
16266
16267 for(int32_t k=0; k<6; k++)
16268 {
16269 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16270 {
16271 return qe_invalid;
16272 }
16273 }
16274
16275 for(int32_t k=0; k<6; k++)
16276 {
16277 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16278 {
16279 return qe_invalid;
16280 }
16281 }
16282
16283 for(int32_t k=0; k<6; k++)
16284 {
16285 if(!p_getc(&tempbyte,f,true)) //layerysize
16286 {
16287 return qe_invalid;
16288 }
16289 }
16290
16291 for(int32_t k=0; k<6; k++)
16292 {
16293 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16294 {
16295 return qe_invalid;
16296 }
16297 }
16298
16299 for(int32_t k=0; k<6; k++)
16300 {
16301 if(!p_getc(&tempbyte,f,true)) //layerydelay
16302 {
16303 return qe_invalid;
16304 }
16305 }
16306 }
16307
16308
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16309 {
16310
2/2
✓ Branch 0 taken 869856 times.
✓ Branch 1 taken 144976 times.
1014832 for(int32_t k=0; k<6; k++)
16311 {
16312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869856 times.
869856 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16313 {
16314 return qe_invalid;
16315 }
16316 869856 }
16317 144976 }
16318
16319
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16320 {
16321
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>153))
16322 {
16323 if(!p_getc(&padding,f,true))
16324 {
16325 return qe_invalid;
16326 }
16327 }
16328
16329
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16330 {
16331 return qe_invalid;
16332 }
16333 144976 }
16334
16335
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16336 {
16337 extras=15;
16338 }
16339
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16340 {
16341 extras=11;
16342 }
16343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16344 {
16345 extras=32;
16346 }
16347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16348 {
16349 extras=64;
16350 }
16351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 else if(Header->zelda_version < 0x193)
16352 {
16353 extras=62;
16354 }
16355 else
16356
16357 {
16358 144976 extras=0;
16359 }
16360
16361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
144976 for(int32_t k=0; k<extras; k++)
16362 {
16363 if(!p_getc(&tempbyte,f,true)) //extra[k]
16364 {
16365 return qe_invalid;
16366 }
16367 }
16368
16369
3/6
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11016 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16370 //if (version>3)
16371 {
16372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16373 {
16374 return qe_invalid;
16375 }
16376
16377
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16378 {
16379 return qe_invalid;
16380 }
16381 133960 }
16382 else
16383 {
16384 11016 temp_mapscr->nextmap=0;
16385 11016 temp_mapscr->nextscr=0;
16386 }
16387
16388
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16389 {
16390 secretcombos=20;
16391 }
16392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144976 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16393 {
16394 secretcombos=256;
16395 }
16396 else
16397 {
16398 144976 secretcombos=128;
16399 }
16400
16401
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16402 {
16403 for(int32_t k=0; k<secretcombos; k++)
16404 {
16405 if(!p_getc(&tempbyte,f,true))
16406 {
16407 return qe_invalid;
16408 }
16409
16410 if(k<128)
16411 {
16412 temp_mapscr->secretcombo[k]=tempbyte;
16413 }
16414 }
16415 }
16416 else
16417 {
16418
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16419 {
16420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16421 {
16422 return qe_invalid;
16423 }
16424
16425 18556928 }
16426 }
16427
16428
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16429 {
16430
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16431 {
16432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16433 {
16434 return qe_invalid;
16435 }
16436 18556928 }
16437
16438
2/2
✓ Branch 0 taken 18556928 times.
✓ Branch 1 taken 144976 times.
18701904 for(int32_t k=0; k<128; k++)
16439 {
16440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18556928 times.
18556928 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16441 {
16442 return qe_invalid;
16443 }
16444 18556928 }
16445 144976 }
16446
16447
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16448 {
16449 if(!p_getc(&padding,f,true))
16450 {
16451 return qe_invalid;
16452 }
16453 }
16454
16455 144976 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16456
16457
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16458 {
16459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16460 {
16461 return qe_invalid;
16462 }
16463 25515776 }
16464
16465
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16466 {
16467 if(!p_getc(&padding,f,true))
16468 {
16469 return qe_invalid;
16470 }
16471
16472 if(!p_getc(&padding,f,true))
16473 {
16474 return qe_invalid;
16475 }
16476 }
16477
16478
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16479 {
16480
2/2
✓ Branch 0 taken 25515776 times.
✓ Branch 1 taken 144976 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16481 {
16482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16483 {
16484 return qe_invalid;
16485 }
16486
16487
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25515776 if((Header->zelda_version == 0x192)&&(Header->build<24))
16488 {
16489 if(!p_getc(&tempbyte,f,true))
16490 {
16491 return qe_invalid;
16492 }
16493
16494 if(!p_getc(&tempbyte,f,true))
16495 {
16496 return qe_invalid;
16497 }
16498
16499 if(!p_getc(&tempbyte,f,true))
16500 {
16501 return qe_invalid;
16502 }
16503 }
16504 25515776 }
16505 144976 }
16506
16507
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16508 {
16509
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 25515776 times.
25660752 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16510 {
16511
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25515776 times.
25515776 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16513 {
16514 return qe_invalid;
16515 }
16516 25515776 }
16517 144976 }
16518
16519
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16520 {
16521 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16522 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16523 }
16524
16525
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16526 {
16527 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16528 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16529 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16530 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16531 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16532 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16533 }
16534
16535
2/6
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144976 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
144976 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16536 {
16537 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16538 {
16539 if((Header->zelda_version == 0x192)&&(Header->build>149))
16540 {
16541 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16542 {
16543 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16544 }
16545 }
16546 else
16547 {
16548 if((Header->zelda_version < 0x192)||
16549 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16550 {
16551 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16552 }
16553
16554 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16555 }
16556
16557 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16558 }
16559 }
16560
16561 /*if(version>12)
16562 {
16563 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16564 {
16565 return qe_invalid;
16566 }
16567 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16568 {
16569 return qe_invalid;
16570 }
16571 }*/
16572
16573
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>4)
16574 {
16575
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16576 {
16577 return qe_invalid;
16578 }
16579 133960 }
16580 else
16581 {
16582 11016 temp_mapscr->screen_midi = -1;
16583 }
16584
16585
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version>=17)
16586 {
16587
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16588 {
16589 return qe_invalid;
16590 }
16591 133960 }
16592 else
16593 {
16594 11016 temp_mapscr->lens_layer = llNORMAL;
16595 }
16596
16597
2/2
✓ Branch 0 taken 11016 times.
✓ Branch 1 taken 133960 times.
144976 if(version>6)
16598 {
16599 dword bits;
16600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_igetl(&bits,f,true))
16601 {
16602 return qe_invalid;
16603 }
16604
16605 int32_t m;
16606 float tempfloat;
16607 word tempw;
16608 133960 temp_mapscr->ffcCountMarkDirty();
16609
16610
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 4286720 times.
4420680 for(m=0; m<32; m++)
16611 {
16612 4286720 ffcdata& tempffc = temp_mapscr->ffcs[m];
16613 4286720 tempffc.clear();
16614
2/2
✓ Branch 0 taken 4275651 times.
✓ Branch 1 taken 11069 times.
4286720 if((bits>>m)&1)
16615 {
16616
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetw(&tempw,f,true))
16617 {
16618 return qe_invalid;
16619 }
16620 11069 tempffc.setData(tempw);
16621
16622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.cset),f,true))
16623 {
16624 return qe_invalid;
16625 }
16626
16627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.delay),f,true))
16628 {
16629 return qe_invalid;
16630 }
16631
16632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(version < 9)
16633 {
16634 if(!p_igetf(&tempfloat,f,true))
16635 {
16636 return qe_invalid;
16637 }
16638
16639 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16640
16641 if(!p_igetf(&tempfloat,f,true))
16642 {
16643 return qe_invalid;
16644 }
16645
16646 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16647
16648 if(!p_igetf(&tempfloat,f,true))
16649 {
16650 return qe_invalid;
16651 }
16652
16653 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16654
16655 if(!p_igetf(&tempfloat,f,true))
16656 {
16657 return qe_invalid;
16658 }
16659
16660 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16661
16662 if(!p_igetf(&tempfloat,f,true))
16663 {
16664 return qe_invalid;
16665 }
16666
16667 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16668
16669 if(!p_igetf(&tempfloat,f,true))
16670 {
16671 return qe_invalid;
16672 }
16673
16674 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16675 }
16676 else
16677 {
16678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.x),f,true))
16679 {
16680 return qe_invalid;
16681 }
16682
16683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.y),f,true))
16684 {
16685 return qe_invalid;
16686 }
16687
16688
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetzf(&(tempffc.vx),f,true))
16689 {
16690 return qe_invalid;
16691 }
16692
16693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.vy),f,true))
16694 {
16695 return qe_invalid;
16696 }
16697
16698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ax),f,true))
16699 {
16700 return qe_invalid;
16701 }
16702
16703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ay),f,true))
16704 {
16705 return qe_invalid;
16706 }
16707 }
16708
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.link),f,true))
16710 {
16711 return qe_invalid;
16712 }
16713
16714
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>7)
16715 {
16716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16717 {
16718 return qe_invalid;
16719 }
16720
16721 11069 tempffc.hxsz = (tempbyte&0x3F)+1;
16722 11069 tempffc.txsz = (tempbyte>>6)+1;
16723
16724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16725 {
16726 return qe_invalid;
16727 }
16728
16729 11069 tempffc.hysz = (tempbyte&0x3F)+1;
16730 11069 tempffc.tysz = (tempbyte>>6)+1;
16731
16732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.flags),f,true))
16733 {
16734 return qe_invalid;
16735 }
16736 11069 }
16737 else
16738 {
16739 tempffc.hxsz=16;
16740 tempffc.hysz=16;
16741 tempffc.txsz=1;
16742 tempffc.tysz=1;
16743 tempffc.flags=0;
16744 }
16745
16746 11069 tempffc.updateSolid();
16747
16748
16749
4/6
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9049 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9049 times.
11069 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16750 {
16751 tempffc.flags|=ffIGNOREHOLDUP;
16752 }
16753
16754
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>9)
16755 {
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.script),f,true))
16757 {
16758 return qe_invalid;
16759 }
16760 11069 }
16761 else
16762 {
16763 tempffc.script=0;
16764 }
16765
16766
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>10)
16767 {
16768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[0]),f,true))
16769 {
16770 return qe_invalid;
16771 }
16772
16773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[1]),f,true))
16774 {
16775 return qe_invalid;
16776 }
16777
16778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[2]),f,true))
16779 {
16780 return qe_invalid;
16781 }
16782
16783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[3]),f,true))
16784 {
16785 return qe_invalid;
16786 }
16787
16788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[4]),f,true))
16789 {
16790 return qe_invalid;
16791 }
16792
16793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[5]),f,true))
16794 {
16795 return qe_invalid;
16796 }
16797
16798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[6]),f,true))
16799 {
16800 return qe_invalid;
16801 }
16802
16803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[7]),f,true))
16804 {
16805 return qe_invalid;
16806 }
16807
16808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16809 {
16810 return qe_invalid;
16811 }
16812
16813 11069 tempffc.inita[0]=tempbyte*10000;
16814
16815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16816 {
16817 return qe_invalid;
16818 }
16819
16820 11069 tempffc.inita[1]=tempbyte*10000;
16821 11069 }
16822 else
16823 {
16824 tempffc.inita[0] = 10000;
16825 tempffc.inita[1] = 10000;
16826 }
16827
16828 11069 tempffc.initialized = false;
16829
16830
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version <= 11)
16831 {
16832 fixffcs=true;
16833 }
16834 11069 }
16835 4286720 }
16836
16837 133960 }
16838
16839 //add in the new whistle flags
16840
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 11016 times.
144976 if(version<13)
16841 {
16842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11016 times.
11016 if(temp_mapscr->flags & fWHISTLE)
16843 {
16844 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16845 }
16846 11016 }
16847
16848 // for(int32_t m=0; m<32; m++)
16849 // {
16850 // // ffcScriptData used to be part of mapscr, and this was handled just above
16851 // ffcScriptData[m].a[0] = 10000;
16852 // ffcScriptData[m].a[1] = 10000;
16853 // }
16854
16855 //2.55 starts here
16856
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 19 && Header->zelda_version > 0x253 )
16857 {
16858
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16859 {
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16861 {
16862 return qe_invalid;
16863 }
16864 137360 }
16865
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16866 {
16867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16868 {
16869 return qe_invalid;
16870 }
16871 137360 }
16872
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16873 {
16874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16875 {
16876 return qe_invalid;
16877 }
16878 137360 }
16879
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16880 {
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16882 {
16883 return qe_invalid;
16884 }
16885 137360 }
16886 13736 }
16887
3/4
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131240 times.
144976 if ( version < 19 && Header->zelda_version > 0x253 )
16888 {
16889 for ( int32_t q = 0; q < 10; q++ )
16890 {
16891 temp_mapscr->npcstrings[q] = 0;
16892 temp_mapscr->new_items[q] = 0;
16893 temp_mapscr->new_item_x[q] = 0;
16894 temp_mapscr->new_item_y[q] = 0;
16895 }
16896 }
16897
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 20 && Header->zelda_version > 0x253 )
16898 {
16899
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
16900 {
16901 return qe_invalid;
16902 }
16903
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16904 {
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16906 {
16907 return qe_invalid;
16908 }
16909 109888 }
16910 13736 }
16911
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
144976 if ( version < 20 )
16912 {
16913 131240 temp_mapscr->script = 0;
16914
2/2
✓ Branch 0 taken 1049920 times.
✓ Branch 1 taken 131240 times.
1181160 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16915 131240 }
16916
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 21 && Header->zelda_version > 0x253 )
16917 {
16918
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16919 {
16920 return qe_invalid;
16921 }
16922 13736 }
16923
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 21 )
16924 {
16925 131240 temp_mapscr->preloadscript = 0;
16926 131240 }
16927 //all builds with version > 20 need this. -Z
16928 144976 temp_mapscr->ffcswaitdraw = 0;
16929
16930
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 131240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
144976 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16931 {
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16933 {
16934 return qe_invalid;
16935 }
16936
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16937 {
16938 return qe_invalid;
16939 }
16940 13736 }
16941
2/2
✓ Branch 0 taken 131240 times.
✓ Branch 1 taken 13736 times.
144976 if ( version < 22 )
16942 {
16943 131240 temp_mapscr->hidelayers = 0;
16944 131240 temp_mapscr->hidescriptlayers = 0;
16945 131240 }
16946
16947 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16948 //May be any version before 2.11. -Z
16949 /* --not the roar, the HIT SFX
16950 if ( Header->zelda_version <= 0x210 )
16951 {
16952 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16953 {
16954 temp_mapscr->bosssfx = WAV_ROAR;
16955 }
16956 }
16957 */
16958
16959 144976 return 0;
16960 144976 }
16961 157216 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16962 {
16963
2/2
✓ Branch 0 taken 144976 times.
✓ Branch 1 taken 12240 times.
157216 if(version < 23)
16964 {
16965 144976 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16966
1/2
✓ Branch 0 taken 144976 times.
✗ Branch 1 not taken.
144976 if(ret) return ret;
16967 144976 }
16968 else
16969 {
16970
1/2
✓ Branch 0 taken 12240 times.
✗ Branch 1 not taken.
12240 if(!p_getc(&(temp_mapscr->valid),f,true))
16971 return qe_invalid;
16972
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 7006 times.
12240 if(!(temp_mapscr->valid & mVALID))
16973 7006 return 0; //Empty screen
16974 uint32_t scr_has_flags;
16975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5234 times.
5234 if(!p_igetl(&scr_has_flags,f,true))
16976 return qe_invalid;
16977
16978
2/2
✓ Branch 0 taken 5189 times.
✓ Branch 1 taken 45 times.
5234 if(scr_has_flags & SCRHAS_ROOMDATA)
16979 {
16980
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
16981 return qe_invalid;
16982
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
16983 return qe_invalid;
16984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
16985 return qe_invalid;
16986
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16987 return qe_invalid;
16988 45 }
16989
2/2
✓ Branch 0 taken 5153 times.
✓ Branch 1 taken 81 times.
5234 if(scr_has_flags & SCRHAS_ITEM)
16990 {
16991
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
16992 return qe_invalid;
16993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16994 return qe_invalid;
16995
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
16996 return qe_invalid;
16997
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
16998 return qe_invalid;
16999 81 }
17000
2/2
✓ Branch 0 taken 4942 times.
✓ Branch 1 taken 292 times.
5234 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17001 {
17002
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17003 return qe_invalid;
17004 292 }
17005
2/2
✓ Branch 0 taken 5036 times.
✓ Branch 1 taken 198 times.
5234 if(scr_has_flags & SCRHAS_TWARP)
17006 {
17007
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17008 {
17009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17010 return qe_invalid;
17011 792 }
17012
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17013 {
17014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17015 return qe_invalid;
17016 792 }
17017
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17018 {
17019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17020 return qe_invalid;
17021 792 }
17022
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17023 return qe_invalid;
17024 198 }
17025
2/2
✓ Branch 0 taken 5116 times.
✓ Branch 1 taken 118 times.
5234 if(scr_has_flags & SCRHAS_SWARP)
17026 {
17027
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17028 {
17029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17030 return qe_invalid;
17031 472 }
17032
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17033 {
17034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17035 return qe_invalid;
17036 472 }
17037
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17038 {
17039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17040 return qe_invalid;
17041 472 }
17042
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17043 return qe_invalid;
17044
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17045 return qe_invalid;
17046 118 }
17047
2/2
✓ Branch 0 taken 4938 times.
✓ Branch 1 taken 296 times.
5234 if(scr_has_flags & SCRHAS_WARPRET)
17048 {
17049
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17050 {
17051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17052 return qe_invalid;
17053 1184 }
17054
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17055 {
17056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17057 return qe_invalid;
17058 1184 }
17059
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17060 return qe_invalid;
17061
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17062 return qe_invalid;
17063 296 }
17064
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 4204 times.
5234 if(scr_has_flags & SCRHAS_LAYERS)
17065 {
17066
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17067 {
17068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17069 return qe_invalid;
17070 6180 }
17071
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17072 {
17073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17074 return qe_invalid;
17075 6180 }
17076
2/2
✓ Branch 0 taken 6180 times.
✓ Branch 1 taken 1030 times.
7210 for(int32_t k=0; k<6; k++)
17077 {
17078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6180 times.
6180 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17079 return qe_invalid;
17080 6180 }
17081
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17082 return qe_invalid;
17083
1/2
✓ Branch 0 taken 1030 times.
✗ Branch 1 not taken.
1030 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17084 return qe_invalid;
17085 1030 }
17086 else
17087 {
17088
2/2
✓ Branch 0 taken 25224 times.
✓ Branch 1 taken 4204 times.
29428 for(int32_t k=0; k<6; k++)
17089 {
17090 25224 temp_mapscr->layeropacity[k] = 255;
17091 25224 }
17092 }
17093
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_MAZE)
17094 {
17095 for(int32_t k=0; k<4; k++)
17096 {
17097 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17098 return qe_invalid;
17099 }
17100 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17101 return qe_invalid;
17102 }
17103
2/2
✓ Branch 0 taken 5138 times.
✓ Branch 1 taken 96 times.
5234 if(scr_has_flags & SCRHAS_D_S_U)
17104 {
17105
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17106 return qe_invalid;
17107
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 96 times.
480 for(int32_t k=0; k<4; k++)
17108 {
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17110 return qe_invalid;
17111 384 }
17112
17113
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairx),f,true))
17114 return qe_invalid;
17115
17116
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->stairy),f,true))
17117 return qe_invalid;
17118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&(temp_mapscr->undercset),f,true))
17121 return qe_invalid;
17122 96 }
17123
2/2
✓ Branch 0 taken 4877 times.
✓ Branch 1 taken 357 times.
5234 if(scr_has_flags & SCRHAS_FLAGS)
17124 {
17125
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags),f,true))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags2),f,true))
17128 return qe_invalid;
17129
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags3),f,true))
17130 return qe_invalid;
17131
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags4),f,true))
17132 return qe_invalid;
17133
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags5),f,true))
17134 return qe_invalid;
17135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->flags6),f,true))
17136 return qe_invalid;
17137
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags7),f,true))
17138 return qe_invalid;
17139
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags8),f,true))
17140 return qe_invalid;
17141
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags9),f,true))
17142 return qe_invalid;
17143
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_getc(&(temp_mapscr->flags10),f,true))
17144 return qe_invalid;
17145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
357 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17146 return qe_invalid;
17147 357 }
17148
2/2
✓ Branch 0 taken 4916 times.
✓ Branch 1 taken 318 times.
5234 if(scr_has_flags & SCRHAS_ENEMY)
17149 {
17150
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17151 {
17152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17153 return qe_invalid;
17154
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17155 temp_mapscr->enemy[k] = 0;
17156 3180 }
17157
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17158 return qe_invalid;
17159 318 }
17160
2/2
✓ Branch 0 taken 5203 times.
✓ Branch 1 taken 31 times.
5234 if(scr_has_flags & SCRHAS_CARRY)
17161 {
17162
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17163 return qe_invalid;
17164
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17165 return qe_invalid;
17166
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17167 return qe_invalid;
17168
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17169 return qe_invalid;
17170 31 }
17171
2/2
✓ Branch 0 taken 5210 times.
✓ Branch 1 taken 24 times.
5234 if(scr_has_flags & SCRHAS_SCRIPT)
17172 {
17173
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17174 return qe_invalid;
17175
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17176 return qe_invalid;
17177
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17178 {
17179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17180 return qe_invalid;
17181 192 }
17182 24 }
17183
1/2
✓ Branch 0 taken 5234 times.
✗ Branch 1 not taken.
5234 if(scr_has_flags & SCRHAS_UNUSED)
17184 {
17185 for ( int32_t q = 0; q < 10; q++ )
17186 {
17187 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17188 return qe_invalid;
17189 }
17190 for ( int32_t q = 0; q < 10; q++ )
17191 {
17192 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17193 return qe_invalid;
17194 }
17195 for ( int32_t q = 0; q < 10; q++ )
17196 {
17197 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17198 return qe_invalid;
17199 }
17200 for ( int32_t q = 0; q < 10; q++ )
17201 {
17202 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17203 return qe_invalid;
17204 }
17205 }
17206
2/2
✓ Branch 0 taken 4889 times.
✓ Branch 1 taken 345 times.
5234 if(scr_has_flags & SCRHAS_SECRETS)
17207 {
17208
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17209 {
17210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17211 return qe_invalid;
17212 44160 }
17213
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17214 {
17215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17216 return qe_invalid;
17217 44160 }
17218
2/2
✓ Branch 0 taken 44160 times.
✓ Branch 1 taken 345 times.
44505 for(int32_t k=0; k<128; k++)
17219 {
17220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44160 times.
44160 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17221 return qe_invalid;
17222 44160 }
17223 345 }
17224
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2375 times.
5234 if(scr_has_flags & SCRHAS_COMBOFLAG)
17225 {
17226
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17227 {
17228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17229 return qe_invalid;
17230 418000 }
17231
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17232 {
17233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17234 return qe_invalid;
17235 418000 }
17236
2/2
✓ Branch 0 taken 418000 times.
✓ Branch 1 taken 2375 times.
420375 for(int32_t k=0; k<176; ++k)
17237 {
17238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418000 times.
418000 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17239 return qe_invalid;
17240 418000 }
17241 2375 }
17242
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 2 times.
5234 if(scr_has_flags & SCRHAS_MISC)
17243 {
17244
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->color),f,true))
17245 return qe_invalid;
17246
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17247 return qe_invalid;
17248
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17249 return qe_invalid;
17250
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17251 return qe_invalid;
17252
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17253 return qe_invalid;
17254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5232 times.
5232 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17255 return qe_invalid;
17256
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17257 return qe_invalid;
17258
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17259 return qe_invalid;
17260
1/2
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
5232 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17261 return qe_invalid;
17262 5232 }
17263 else
17264 {
17265 2 temp_mapscr->screen_midi = -1;
17266 2 temp_mapscr->csensitive = 1;
17267 }
17268 //FFC
17269 5234 bool old_ff = version < 25;
17270 5234 dword bits = 0;
17271 5234 word numffc = 32;
17272
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 5157 times.
5234 if(old_ff)
17273 {
17274
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetl(&bits,f,true))
17275 return qe_invalid;
17276 77 }
17277 else
17278 {
17279
1/2
✓ Branch 0 taken 5157 times.
✗ Branch 1 not taken.
5157 if(!p_igetw(&numffc,f,true))
17280 return qe_invalid;
17281 }
17282 byte tempbyte;
17283 word tempw;
17284
4/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 5215 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19 times.
5234 static ffcdata nil_ffc;
17285 5234 temp_mapscr->ffcCountMarkDirty();
17286
2/2
✓ Branch 0 taken 5234 times.
✓ Branch 1 taken 8545 times.
13779 for(word m = 0; m < numffc; ++m)
17287 {
17288
1/2
✓ Branch 0 taken 8545 times.
✗ Branch 1 not taken.
8545 ffcdata& tempffc = (m < MAXFFCS)
17289 8545 ? temp_mapscr->ffcs[m]
17290 : nil_ffc; //sanity
17291 8545 tempffc.clear();
17292
3/4
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 6081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
8545 if(old_ff && !(bits & (1<<m))) continue;
17293
17294
1/2
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
6081 if(!p_igetw(&tempw,f,true))
17295 return qe_invalid;
17296
3/4
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5116 times.
6081 if(!old_ff && !tempw) //empty ffc, nothing more to load
17297 5116 continue;
17298 965 tempffc.setData(tempw);
17299
17300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17301 return qe_invalid;
17302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17303 return qe_invalid;
17304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17305 return qe_invalid;
17306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17307 return qe_invalid;
17308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17309 return qe_invalid;
17310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17311 return qe_invalid;
17312
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17313 return qe_invalid;
17314
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17315 return qe_invalid;
17316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17317 return qe_invalid;
17318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17319 {
17320 if(!p_getc(&tempbyte,f,true))
17321 return qe_invalid;
17322 tempffc.hxsz = (tempbyte&0x3F)+1;
17323 tempffc.txsz = (tempbyte>>6)+1;
17324 if(!p_getc(&tempbyte,f,true))
17325 return qe_invalid;
17326 tempffc.hysz = (tempbyte&0x3F)+1;
17327 tempffc.tysz = (tempbyte>>6)+1;
17328 }
17329 else
17330 {
17331
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17332 return qe_invalid;
17333
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17334 return qe_invalid;
17335
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17336 return qe_invalid;
17337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17338 return qe_invalid;
17339 }
17340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17341 return qe_invalid;
17342 965 tempffc.updateSolid();
17343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17344 return qe_invalid;
17345
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17346 {
17347
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17348 return qe_invalid;
17349 7720 }
17350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17351 return qe_invalid;
17352 965 tempffc.inita[0]=tempbyte*10000;
17353
17354
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17355 return qe_invalid;
17356 965 tempffc.inita[1]=tempbyte*10000;
17357
17358 965 tempffc.initialized = false;
17359 965 }
17360
2/2
✓ Branch 0 taken 661407 times.
✓ Branch 1 taken 5234 times.
666641 for(word m = numffc; m < MAXFFCS; ++m)
17361 {
17362 661407 temp_mapscr->ffcs[m].clear();
17363 661407 }
17364 //END FFC
17365 }
17366 150210 return 0;
17367 157216 }
17368
17369
17370 99 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17371 {
17372 99 int32_t scr=0;
17373
17374 99 word version=0;
17375 dword dummy;
17376 int32_t screens_to_read;
17377
17378 99 mapscr temp_mapscr;
17379 zcmap temp_map;
17380 word temp_map_count;
17381 dword section_size;
17382
17383
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17384 {
17385 screens_to_read=MAPSCRS192b136;
17386 }
17387 else
17388 {
17389 99 screens_to_read=MAPSCRS;
17390 }
17391
17392
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
17393 {
17394 //section version info
17395
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&version,f,true))
17396 {
17397 return qe_invalid;
17398 }
17399
17400 99 FFCore.quest_format[vMaps] = version;
17401
17402 //al_trace("Maps version %d\n", version);
17403
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
17404 {
17405 return qe_invalid;
17406 }
17407
17408 //section size
17409
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
17410 {
17411 return qe_invalid;
17412 }
17413
17414 //finally... section data
17415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_igetw(&temp_map_count,f,true))
17416 {
17417 return 5;
17418 }
17419 99 }
17420 else
17421 {
17422 temp_map_count=map_count;
17423 }
17424
17425
17426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17427 {
17428 99 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17429 99 TheMaps.resize(_mapsSize);
17430
17431
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 99 times.
158267 for(int32_t i(0); i<_mapsSize; i++)
17432 158168 TheMaps[i].zero_memory();
17433
17434 // Used to be done for each screen
17435
2/2
✓ Branch 0 taken 12672 times.
✓ Branch 1 taken 99 times.
12771 for(int32_t i=0; i<MAXFFCS; i++)
17436 {
17437 12672 ffcScriptData[i].a[0] = 10000;
17438 12672 ffcScriptData[i].a[1] = 10000;
17439 12672 }
17440
17441 99 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17442 99 }
17443
17444 99 temp_mapscr.zero_memory();
17445
17446 99 memset(&temp_map, 0, sizeof(zcmap));
17447 99 temp_map.scrResWidth = 256;
17448 99 temp_map.scrResHeight = 224;
17449 99 temp_map.tileWidth = 16;
17450 99 temp_map.tileHeight = 11;
17451 99 temp_map.viewWidth = 256;
17452 99 temp_map.viewHeight = 176;
17453 99 temp_map.viewX = 0;
17454 99 temp_map.viewY = 64;
17455 99 temp_map.subaWidth = 256;
17456 99 temp_map.subaHeight = 168;
17457 99 temp_map.subaTrans = false;
17458 99 temp_map.subpWidth = 256;
17459 99 temp_map.subpHeight = 56;
17460 99 temp_map.subpTrans = false;
17461
4/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1163 times.
✓ Branch 2 taken 1163 times.
✓ Branch 3 taken 99 times.
1262 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17462 {
17463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true) //!TODO Trim fully
17464 {
17465 1163 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17466 1163 }
17467 1163 byte valid=1;
17468
2/2
✓ Branch 0 taken 1066 times.
✓ Branch 1 taken 97 times.
1163 if(version > 22)
17469 {
17470
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&valid,f,true))
17471 return qe_invalid;
17472 97 }
17473
2/2
✓ Branch 0 taken 158168 times.
✓ Branch 1 taken 1163 times.
159331 for(int32_t j=0; j<screens_to_read; j++)
17474 {
17475 158168 scr=i*MAPSCRS+j;
17476 158168 clear_screen(&temp_mapscr);
17477
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 157216 times.
158168 if(valid)
17478 157216 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17479
17480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158168 times.
158168 if(keepdata==true)
17481 {
17482 158168 TheMaps[scr] = temp_mapscr;
17483 158168 }
17484 158168 }
17485
17486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1163 times.
1163 if(keepdata==true)
17487 {
17488
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17489 {
17490 int32_t index = (i*MAPSCRS+132);
17491
17492 TheMaps[index]=TheMaps[index-1];
17493
17494 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17495 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17496 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17497
17498 for(int32_t j=133; j<MAPSCRS; j++)
17499 {
17500 scr=i*MAPSCRS+j;
17501
17502 TheMaps[scr].zero_memory();
17503 TheMaps[scr].valid = mVERSION;
17504 TheMaps[scr].screen_midi = -1;
17505 TheMaps[scr].csensitive = 1;
17506 }
17507 }
17508
17509
2/6
✓ Branch 0 taken 1163 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1163 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1163 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17510 {
17511 for(int32_t j=0; j<MAPSCRS; j++)
17512 {
17513 scr=i*MAPSCRS+j;
17514 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17515
17516 for(int32_t k=0; k<128; k++)
17517 {
17518 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17519 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17520 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17521 }
17522 }
17523 }
17524 1163 }
17525 1163 }
17526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
17527 {
17528 99 map_count = temp_map_count;
17529 99 }
17530 99 clear_screen(&temp_mapscr);
17531 99 return 0;
17532 99 }
17533
17534
17535 79 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17536 {
17537 79 reset_combo_animations();
17538 79 reset_combo_animations2();
17539
17540 79 init_combo_classes();
17541
17542 // combos
17543 79 word combos_used=0;
17544 int32_t dummy;
17545 byte padding;
17546 79 newcombo temp_combo;
17547 //word section_cversion=0;
17548
17549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
17550 {
17551
2/2
✓ Branch 0 taken 5157120 times.
✓ Branch 1 taken 79 times.
5157199 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17552 5157120 combobuf[q].clear();
17553 79 }
17554
17555 // if(version > 0x192)
17556 // {
17557 // //section version info
17558 // if(!p_igetw(&section_version,f,true))
17559 // {
17560 // return qe_invalid;
17561 // }
17562
17563 // FFCore.quest_format[vCombos] = section_version;
17564
17565 // //al_trace("Combos version %d\n", section_version);
17566 // if(!p_igetw(&section_cversion,f,true))
17567 // {
17568 // return qe_invalid;
17569 // }
17570
17571 // //section size
17572 // if(!p_igetl(&dummy,f,true))
17573 // {
17574 // return qe_invalid;
17575 // }
17576 // }
17577
17578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(version < 0x174)
17579 {
17580 combos_used=1024;
17581 }
17582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 else if(version < 0x191)
17583 {
17584 combos_used=2048;
17585 }
17586 else
17587 {
17588
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&combos_used,f,true))
17589 {
17590 return qe_invalid;
17591 }
17592 }
17593
17594 //finally... section data
17595
2/2
✓ Branch 0 taken 367401 times.
✓ Branch 1 taken 79 times.
367480 for(int32_t i=0; i<combos_used; i++)
17596 {
17597 367401 temp_combo.clear();
17598
17599
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if ( section_version >= 11 )
17600 {
17601
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17602 {
17603 return qe_invalid;
17604 }
17605 68884 }
17606 else
17607 {
17608
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 if(!p_igetw(&temp_combo.tile,f,true))
17609 {
17610 return qe_invalid;
17611 }
17612 }
17613 367401 temp_combo.o_tile = temp_combo.tile;
17614
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.flip,f,true))
17615 {
17616 return qe_invalid;
17617 }
17618
17619
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.walk,f,true))
17620 {
17621 return qe_invalid;
17622 }
17623
17624
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.type,f,true))
17625 {
17626 return qe_invalid;
17627 }
17628
17629
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.csets,f,true))
17630 {
17631 return qe_invalid;
17632 }
17633
17634
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
17635 {
17636 if(!p_getc(&padding,f,true))
17637 {
17638 return qe_invalid;
17639 }
17640
17641 if(!p_getc(&padding,f,true))
17642 {
17643 return qe_invalid;
17644 }
17645
17646 if(version < 0x192)
17647 {
17648 if(version == 0x191)
17649 {
17650 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17651 {
17652 if(!p_getc(&padding,f,true))
17653 {
17654 return qe_invalid;
17655 }
17656 }
17657 }
17658
17659 if(keepdata==true)
17660 {
17661 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17662 }
17663
17664 continue;
17665 }
17666 }
17667
17668
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.frames,f,true))
17669 {
17670 return qe_invalid;
17671 }
17672
17673
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.speed,f,true))
17674 {
17675 return qe_invalid;
17676 }
17677
17678
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_igetw(&temp_combo.nextcombo,f,true))
17679 {
17680 return qe_invalid;
17681 }
17682
17683
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(!p_getc(&temp_combo.nextcset,f,true))
17684 {
17685 return qe_invalid;
17686 }
17687
17688 //Base flag
17689
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=3)
17690 {
17691
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.flag,f,true))
17692 {
17693 return qe_invalid;
17694 }
17695 360207 }
17696
17697
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=4)
17698 {
17699
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanim,f,true))
17700 {
17701 return qe_invalid;
17702 }
17703
17704
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_igetw(&temp_combo.nexttimer,f,true))
17705 {
17706 return qe_invalid;
17707 }
17708 360207 }
17709
17710
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=5)
17711 {
17712
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanimy,f,true))
17713 {
17714 return qe_invalid;
17715 }
17716 360207 }
17717
17718
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 360207 times.
367401 if(section_version>=6)
17719 {
17720
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.animflags,f,true))
17721 {
17722 return qe_invalid;
17723 }
17724
17725
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(section_version == 6)
17726 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17727 360207 }
17728
17729
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=8) //combo Attributes[4] and userflags.
17730 {
17731
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17732 {
17733
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17734 {
17735 return qe_invalid;
17736 }
17737 275536 }
17738
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17739 {
17740 return qe_invalid;
17741 }
17742
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17743 {
17744
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17745 {
17746 return qe_invalid;
17747 }
17748 68884 }
17749 else
17750 {
17751 temp_combo.genflags = 0;
17752 switch(temp_combo.type)
17753 {
17754 case cPUSH_WAIT: case cPUSH_HEAVY:
17755 case cPUSH_HW: case cL_STATUE:
17756 case cR_STATUE: case cPUSH_HEAVY2:
17757 case cPUSH_HW2: case cPOUND:
17758 case cC_STATUE: case cMIRROR:
17759 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17760 case cMAGICPRISM: case cMAGICPRISM4:
17761 case cMAGICSPONGE: case cEYEBALL_A:
17762 case cEYEBALL_B: case cEYEBALL_4:
17763 case cBUSH: case cFLOWERS:
17764 case cLOCKBLOCK: case cLOCKBLOCK2:
17765 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17766 case cCHEST: case cCHEST2:
17767 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17768 case cBOSSCHEST: case cBOSSCHEST2:
17769 case cBUSHNEXT: case cBUSHTOUCHY:
17770 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17771 case cSIGNPOST: case cCSWITCHBLOCK:
17772 case cTORCH: case cTRIGGERGENERIC:
17773 if(temp_combo.usrflags & cflag16)
17774 {
17775 temp_combo.genflags |= cflag1;
17776 temp_combo.usrflags &= ~cflag16;
17777 }
17778 break; }
17779 }
17780 68884 }
17781
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=10) //combo trigger flags
17782 {
17783
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17784 {
17785
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17786 {
17787 return qe_invalid;
17788 }
17789 206652 }
17790 68884 }
17791
1/2
✓ Branch 0 taken 298517 times.
✗ Branch 1 not taken.
298517 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17792 {
17793 for ( int32_t q = 0; q < 2; q++ )
17794 {
17795 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17796 {
17797 return qe_invalid;
17798 }
17799 }
17800 }
17801
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 9)
17802 {
17803
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17804 {
17805 return qe_invalid;
17806 }
17807 68884 }
17808
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version >= 22)
17809 {
17810
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17811 {
17812 return qe_invalid;
17813 }
17814 68884 }
17815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 23)
17816 {
17817
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 367253 times.
367401 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17818 {
17819 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17820 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17821 case cTRIGGERGENERIC: case cCSWITCH:
17822 148 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17823 148 }
17824 367401 }
17825
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 24)
17826 {
17827 if(!p_getc(&temp_combo.triggeritem,f,true))
17828 {
17829 return qe_invalid;
17830 }
17831 if(!p_getc(&temp_combo.trigtimer,f,true))
17832 {
17833 return qe_invalid;
17834 }
17835 }
17836
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(section_version >= 25)
17837 {
17838 if(!p_getc(&temp_combo.trigsfx,f,true))
17839 {
17840 return qe_invalid;
17841 }
17842 }
17843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 27)
17844 {
17845 if(!p_igetl(&temp_combo.trigchange,f,true))
17846 {
17847 return qe_invalid;
17848 }
17849 }
17850 else
17851 {
17852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17853 temp_combo.trigchange = 1;
17854
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17855 temp_combo.trigchange = -1;
17856 367401 else temp_combo.trigchange = 0;
17857 367401 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17858 }
17859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 29)
17860 {
17861 if(!p_igetw(&temp_combo.trigprox,f,true))
17862 {
17863 return qe_invalid;
17864 }
17865 if(!p_getc(&temp_combo.trigctr,f,true))
17866 {
17867 return qe_invalid;
17868 }
17869 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17870 {
17871 return qe_invalid;
17872 }
17873 }
17874 else
17875 {
17876 367401 temp_combo.trigprox = 0;
17877 367401 temp_combo.trigctr = 0;
17878 367401 temp_combo.trigctramnt = 0;
17879 }
17880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 30)
17881 {
17882 if(!p_getc(&temp_combo.triglbeam,f,true))
17883 {
17884 return qe_invalid;
17885 }
17886 }
17887 367401 else temp_combo.triglbeam = 0;
17888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 31)
17889 {
17890 if(!p_getc(&temp_combo.trigcschange,f,true))
17891 {
17892 return qe_invalid;
17893 }
17894 if(!p_igetw(&temp_combo.spawnitem,f,true))
17895 {
17896 return qe_invalid;
17897 }
17898 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17899 {
17900 return qe_invalid;
17901 }
17902 if(!p_getc(&temp_combo.exstate,f,true))
17903 {
17904 return qe_invalid;
17905 }
17906 if(!p_igetl(&temp_combo.spawnip,f,true))
17907 {
17908 return qe_invalid;
17909 }
17910 if(!p_getc(&temp_combo.trigcopycat,f,true))
17911 {
17912 return qe_invalid;
17913 }
17914 }
17915 else
17916 {
17917 367401 temp_combo.trigcschange = 0;
17918 367401 temp_combo.spawnitem = 0;
17919 367401 temp_combo.spawnenemy = 0;
17920 367401 temp_combo.exstate = -1;
17921 367401 temp_combo.spawnip = 0;
17922 367401 temp_combo.trigcopycat = 0;
17923 }
17924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version >= 32)
17925 {
17926 if(!p_getc(&temp_combo.trigcooldown,f,true))
17927 {
17928 return qe_invalid;
17929 }
17930 }
17931 else
17932 {
17933 367401 temp_combo.trigcooldown = 0;
17934 }
17935
17936
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=12) //combo label
17937 {
17938
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17939 {
17940
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17941 {
17942 return qe_invalid;
17943 }
17944 757724 }
17945 68884 }
17946
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<12) //combo label
17947 {
17948
2/2
✓ Branch 0 taken 3283687 times.
✓ Branch 1 taken 298517 times.
3582204 for ( int32_t q = 0; q < 11; q++ )
17949 {
17950 3283687 temp_combo.label[q] = 0;
17951 3283687 }
17952 298517 }
17953 //al_trace("Read combo label\n");
17954
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=13) //attribytes[4]
17955 {
17956
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17957 {
17958
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17959 {
17960 return qe_invalid;
17961 }
17962 275536 }
17963
17964 68884 }
17965 //al_trace("Read combo attribytes\n");
17966
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if( section_version < 13 )
17967 {
17968
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17969 {
17970 1194068 temp_combo.attribytes[q] = 0;
17971 1194068 }
17972
17973 298517 }
17974 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17975 * This fixes a poor implementation of a ->next flag bug thing.
17976 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17977 * there was a version bump a few weeks before a change that broke stuff.
17978 */
17979
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
367401 if (section_version >= 13 && section_version < 21)
17980 {
17981 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17982 }
17983 //combo scripts
17984
2/2
✓ Branch 0 taken 298517 times.
✓ Branch 1 taken 68884 times.
367401 if(section_version>=14)
17985 {
17986
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
17987
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17988 {
17989
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17990 {
17991 return qe_invalid;
17992 }
17993 137768 }
17994
17995 68884 }
17996
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<14)
17997 {
17998 298517 temp_combo.script = 0;
17999
2/2
✓ Branch 0 taken 597034 times.
✓ Branch 1 taken 298517 times.
895551 for ( int32_t q = 0; q < 2; q++ )
18000 {
18001 597034 temp_combo.initd[q] = 0;
18002 597034 }
18003 298517 }
18004 //al_trace("Read combo script data\n");
18005
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=15)
18006 {
18007
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
18008
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
18009
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
18010
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
18011 68884 }
18012 else
18013 {
18014 298517 temp_combo.o_tile = temp_combo.tile;
18015 298517 temp_combo.cur_frame = 0;
18016 298517 temp_combo.aclk = 0;
18017 }
18018
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version>=17) //attribytes[4]
18019 {
18020
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18021 {
18022
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
18023 {
18024 return qe_invalid;
18025 }
18026 275536 }
18027
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18028 {
18029
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18030 {
18031 return qe_invalid;
18032 }
18033 551072 }
18034
18035 68884 }
18036 else
18037 {
18038
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18039 {
18040 1194068 temp_combo.attribytes[q] = 0;
18041 1194068 }
18042
2/2
✓ Branch 0 taken 2388136 times.
✓ Branch 1 taken 298517 times.
2686653 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18043 {
18044 2388136 temp_combo.attrishorts[q] = 0;
18045 2388136 }
18046 }
18047
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version<18) //upper bits for .walk
18048 {
18049 298517 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18050 298517 }
18051
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 298517 times.
367401 if(section_version < 19)
18052 {
18053
2/2
✓ Branch 0 taken 1194068 times.
✓ Branch 1 taken 298517 times.
1492585 for(int32_t q = 0; q < 4; ++q)
18054 {
18055 1194068 temp_combo.attributes[q] *= 10000L;
18056 1194068 }
18057 298517 }
18058
18059
1/2
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
367401 if(version < 0x193)
18060 {
18061 for(int32_t q=0; q<11; q++)
18062 {
18063 if(!p_getc(&dummy,f,true))
18064 {
18065 return qe_invalid;
18066 }
18067 }
18068 }
18069
18070 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18071
3/6
✓ Branch 0 taken 360207 times.
✓ Branch 1 taken 7194 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
367401 if((version < 0x211)||((version == 0x211)&&(build<7)))
18072 {
18073
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18074 {
18075 switch(temp_combo.tile)
18076 {
18077 case 130:
18078 temp_combo.tile = 132;
18079 break;
18080
18081 case 131:
18082 temp_combo.tile = 133;
18083 break;
18084
18085 case 132:
18086 temp_combo.tile = 130;
18087 break;
18088
18089 case 133:
18090 temp_combo.tile = 131;
18091 break;
18092 }
18093 }
18094 7194 }
18095
18096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 25)
18097 {
18098
2/2
✓ Branch 0 taken 2517 times.
✓ Branch 1 taken 364884 times.
367401 switch(temp_combo.type)
18099 {
18100 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2517 times.
2517 if(!(temp_combo.usrflags & cflag3))
18102 2517 temp_combo.attribytes[3] = WAV_DOOR;
18103 2517 temp_combo.usrflags &= ~cflag3;
18104 2517 break;
18105 }
18106 367401 }
18107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 26)
18108 {
18109
2/2
✓ Branch 0 taken 366902 times.
✓ Branch 1 taken 499 times.
367401 if(temp_combo.type == cARMOS)
18110 {
18111
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(temp_combo.usrflags & cflag1)
18112 temp_combo.usrflags |= cflag3;
18113 499 }
18114 367401 }
18115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367401 times.
367401 if(section_version < 28)
18116 {
18117
2/2
✓ Branch 0 taken 1316 times.
✓ Branch 1 taken 366085 times.
367401 switch(temp_combo.type)
18118 {
18119 case cLOCKBLOCK: case cLOCKEDCHEST:
18120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
1316 if(temp_combo.usrflags & cflag7)
18121 temp_combo.usrflags |= cflag8;
18122 1316 else temp_combo.usrflags &= ~cflag8;
18123 1316 temp_combo.usrflags &= ~cflag7;
18124 1316 break;
18125 }
18126
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 367332 times.
367401 switch(temp_combo.type)
18127 {
18128 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18129 69 temp_combo.attrishorts[2] = -1;
18130 69 temp_combo.usrflags |= cflag7;
18131 69 break;
18132 }
18133 367401 }
18134
18135
2/4
✓ Branch 0 taken 367401 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 367401 times.
367401 if(keepdata==true && i>=start_combo)
18136 {
18137 367401 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18138 367401 }
18139 367401 }
18140
18141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(keepdata==true)
18142 {
18143
2/6
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18144 {
18145 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18146 {
18147 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18148 {
18149 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18150 }
18151 }
18152 }
18153
18154 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18155
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(version == 0x210 && !is_zquest())
18156 {
18157
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18158
1/2
✓ Branch 0 taken 195840 times.
✗ Branch 1 not taken.
195840 if(combobuf[tmpcounter].type == cLADDERONLY)
18159 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18160 3 }
18161
18162
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 3 times.
79 if(section_version<7)
18163 {
18164
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 3 times.
195843 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18165 {
18166
2/9
✓ Branch 0 taken 195837 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
195840 switch(combobuf[tmpcounter].type)
18167 {
18168 case cSLASH:
18169 3 combobuf[tmpcounter].type=cSLASHTOUCHY;
18170 3 break;
18171
18172 case cSLASHITEM:
18173 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18174 break;
18175
18176 case cBUSH:
18177 combobuf[tmpcounter].type=cBUSHTOUCHY;
18178 break;
18179
18180 case cFLOWERS:
18181 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18182 break;
18183
18184 case cTALLGRASS:
18185 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18186 break;
18187
18188 case cSLASHNEXT:
18189 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18190 break;
18191
18192 case cSLASHNEXTITEM:
18193 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18194 break;
18195
18196 case cBUSHNEXT:
18197 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18198 break;
18199 }
18200 195840 }
18201 3 }
18202
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77 times.
79 if (section_version < 16)
18203 {
18204
2/2
✓ Branch 0 taken 5026560 times.
✓ Branch 1 taken 77 times.
5026637 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18205 {
18206
2/2
✓ Branch 0 taken 5022039 times.
✓ Branch 1 taken 4521 times.
5026560 if (combobuf[tmpcounter].type == cWATER)
18207 {
18208 4521 combobuf[tmpcounter].attributes[0] = 40000L;
18209 4521 }
18210 5026560 }
18211 77 }
18212
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1 times.
79 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18213 {
18214 1 combobuf[0].walk = 0xF0;
18215 1 combobuf[0].type = 0;
18216 1 combobuf[0].flag = 0;
18217 1 }
18218 79 }
18219
18220 //Now for the new combo alias reset
18221
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
79 if(section_version<2 && keepdata)
18222 {
18223
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 3 times.
24579 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18224 {
18225 24576 combo_aliases[j].width = 0;
18226 24576 combo_aliases[j].height = 0;
18227 24576 combo_aliases[j].layermask = 0;
18228
18229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].combos != NULL)
18230 {
18231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 delete[] combo_aliases[j].combos;
18232 24576 }
18233
18234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 if(combo_aliases[j].csets != NULL)
18235 {
18236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24576 times.
24576 delete[] combo_aliases[j].csets;
18237 24576 }
18238
18239 24576 combo_aliases[j].combos = new word[1];
18240 24576 combo_aliases[j].csets = new byte[1];
18241 24576 combo_aliases[j].combos[0] = 0;
18242 24576 combo_aliases[j].csets[0] = 0;
18243 24576 }
18244 3 }
18245
18246
18247 79 setup_combo_animations();
18248 79 setup_combo_animations2();
18249 79 return 0;
18250 79 }
18251 131498 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18252 {
18253 byte combo_has_flags;
18254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131498 times.
131498 if(!p_getc(&combo_has_flags,f,true))
18255 return qe_invalid;
18256
18257 131498 temp_combo.clear();
18258
2/2
✓ Branch 0 taken 84766 times.
✓ Branch 1 taken 46732 times.
131498 if(combo_has_flags)
18259 {
18260
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 46729 times.
46732 if(combo_has_flags&CHAS_GENERAL)
18261 {
18262
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_igetl(&temp_combo.tile,f,true))
18263 {
18264 return qe_invalid;
18265 }
18266 46729 temp_combo.o_tile = temp_combo.tile;
18267
18268
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flip,f,true))
18269 {
18270 return qe_invalid;
18271 }
18272
18273
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.walk,f,true))
18274 {
18275 return qe_invalid;
18276 }
18277
18278
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.type,f,true))
18279 {
18280 return qe_invalid;
18281 }
18282
18283
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.flag,f,true))
18284 {
18285 return qe_invalid;
18286 }
18287
18288
1/2
✓ Branch 0 taken 46729 times.
✗ Branch 1 not taken.
46729 if(!p_getc(&temp_combo.csets,f,true))
18289 {
18290 return qe_invalid;
18291 }
18292 46729 }
18293
2/2
✓ Branch 0 taken 46716 times.
✓ Branch 1 taken 16 times.
46732 if(combo_has_flags&CHAS_SCRIPT)
18294 {
18295
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 for ( int32_t q = 0; q < 11; q++ )
18296 {
18297
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&temp_combo.label[q],f,true))
18298 {
18299 return qe_invalid;
18300 }
18301 176 }
18302
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18303
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
48 for ( int32_t q = 0; q < 2; q++ )
18304 {
18305
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetl(&temp_combo.initd[q],f,true))
18306 {
18307 return qe_invalid;
18308 }
18309 32 }
18310 16 }
18311
2/2
✓ Branch 0 taken 33663 times.
✓ Branch 1 taken 13069 times.
46732 if(combo_has_flags&CHAS_ANIM)
18312 {
18313
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.frames,f,true))
18314 {
18315 return qe_invalid;
18316 }
18317
18318
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.speed,f,true))
18319 {
18320 return qe_invalid;
18321 }
18322
18323
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_igetw(&temp_combo.nextcombo,f,true))
18324 {
18325 return qe_invalid;
18326 }
18327
18328
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.nextcset,f,true))
18329 {
18330 return qe_invalid;
18331 }
18332
18333
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanim,f,true))
18334 {
18335 return qe_invalid;
18336 }
18337
18338
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.skipanimy,f,true))
18339 {
18340 return qe_invalid;
18341 }
18342
18343
1/2
✓ Branch 0 taken 13069 times.
✗ Branch 1 not taken.
13069 if(!p_getc(&temp_combo.animflags,f,true))
18344 {
18345 return qe_invalid;
18346 }
18347 13069 }
18348
2/2
✓ Branch 0 taken 42653 times.
✓ Branch 1 taken 4079 times.
46732 if(combo_has_flags&CHAS_ATTRIB)
18349 {
18350
2/2
✓ Branch 0 taken 16316 times.
✓ Branch 1 taken 4079 times.
20395 for ( int32_t q = 0; q < 4; q++ )
18351 {
18352
1/2
✓ Branch 0 taken 16316 times.
✗ Branch 1 not taken.
16316 if(!p_igetl(&temp_combo.attributes[q],f,true))
18353 {
18354 return qe_invalid;
18355 }
18356 16316 }
18357
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18358 {
18359
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_getc(&temp_combo.attribytes[q],f,true))
18360 {
18361 return qe_invalid;
18362 }
18363 32632 }
18364
2/2
✓ Branch 0 taken 32632 times.
✓ Branch 1 taken 4079 times.
36711 for ( int32_t q = 0; q < 8; q++ )
18365 {
18366
1/2
✓ Branch 0 taken 32632 times.
✗ Branch 1 not taken.
32632 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18367 {
18368 return qe_invalid;
18369 }
18370 32632 }
18371 4079 }
18372
2/2
✓ Branch 0 taken 45433 times.
✓ Branch 1 taken 1299 times.
46732 if(combo_has_flags&CHAS_FLAG)
18373 {
18374
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetl(&temp_combo.usrflags,f,true))
18375 {
18376 return qe_invalid;
18377 }
18378
1/2
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
1299 if(!p_igetw(&temp_combo.genflags,f,true))
18379 {
18380 return qe_invalid;
18381 }
18382 1299 }
18383
2/2
✓ Branch 0 taken 46405 times.
✓ Branch 1 taken 327 times.
46732 if(combo_has_flags&CHAS_TRIG)
18384 {
18385
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 327 times.
1308 for ( int32_t q = 0; q < 3; q++ )
18386 {
18387
1/2
✓ Branch 0 taken 981 times.
✗ Branch 1 not taken.
981 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18388 {
18389 return qe_invalid;
18390 }
18391 981 }
18392
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18393 {
18394 return qe_invalid;
18395 }
18396
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggerbtn,f,true))
18397 {
18398 return qe_invalid;
18399 }
18400
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triggeritem,f,true))
18401 {
18402 return qe_invalid;
18403 }
18404
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigtimer,f,true))
18405 {
18406 return qe_invalid;
18407 }
18408
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigsfx,f,true))
18409 {
18410 return qe_invalid;
18411 }
18412
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigchange,f,true))
18413 {
18414 return qe_invalid;
18415 }
18416
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.trigprox,f,true))
18417 {
18418 return qe_invalid;
18419 }
18420
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigctr,f,true))
18421 {
18422 return qe_invalid;
18423 }
18424
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18425 {
18426 return qe_invalid;
18427 }
18428
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.triglbeam,f,true))
18429 {
18430 return qe_invalid;
18431 }
18432
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcschange,f,true))
18433 {
18434 return qe_invalid;
18435 }
18436
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnitem,f,true))
18437 {
18438 return qe_invalid;
18439 }
18440
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18441 {
18442 return qe_invalid;
18443 }
18444
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.exstate,f,true))
18445 {
18446 return qe_invalid;
18447 }
18448
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetl(&temp_combo.spawnip,f,true))
18449 {
18450 return qe_invalid;
18451 }
18452
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcopycat,f,true))
18453 {
18454 return qe_invalid;
18455 }
18456
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.trigcooldown,f,true))
18457 {
18458 return qe_invalid;
18459 }
18460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(s_version >= 35)
18461 {
18462
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18463 {
18464 return qe_invalid;
18465 }
18466
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_getc(&temp_combo.prompt_cs,f,true))
18467 {
18468 return qe_invalid;
18469 }
18470
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 if(!p_igetw(&temp_combo.prompt_x,f,true))
18471 {
18472 return qe_invalid;
18473 }
18474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
327 if(!p_igetw(&temp_combo.prompt_y,f,true))
18475 {
18476 return qe_invalid;
18477 }
18478 327 }
18479 327 }
18480
2/2
✓ Branch 0 taken 46657 times.
✓ Branch 1 taken 75 times.
46732 if(combo_has_flags&CHAS_LIFT)
18481 {
18482
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftcmb,f,true))
18483 return qe_invalid;
18484
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftcs,f,true))
18485 return qe_invalid;
18486
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18487 return qe_invalid;
18488
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftundercs,f,true))
18489 return qe_invalid;
18490
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftdmg,f,true))
18491 return qe_invalid;
18492
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftlvl,f,true))
18493 return qe_invalid;
18494
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftitm,f,true))
18495 return qe_invalid;
18496
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftflags,f,true))
18497 return qe_invalid;
18498
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftgfx,f,true))
18499 return qe_invalid;
18500
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsprite,f,true))
18501 return qe_invalid;
18502
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftsfx,f,true))
18503 return qe_invalid;
18504
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18505 return qe_invalid;
18506
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18507 return qe_invalid;
18508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(s_version >= 34)
18509 {
18510
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifthei,f,true))
18511 return qe_invalid;
18512
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&temp_combo.lifttime,f,true))
18513 return qe_invalid;
18514 75 }
18515 75 }
18516 46732 }
18517 131498 return 0;
18518 131498 }
18519 99 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18520 {
18521 99 word section_version=0;
18522 99 word section_cversion=0;
18523 99 word combos_used=0;
18524 int32_t dummy;
18525 byte padding;
18526 99 newcombo temp_combo;
18527
18528 99 reset_combo_animations();
18529 99 reset_combo_animations2();
18530 99 init_combo_classes();
18531
18532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true) //reset combos
18533 {
18534
2/2
✓ Branch 0 taken 6462720 times.
✓ Branch 1 taken 99 times.
6462819 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18535 6462720 combobuf[q].clear();
18536 99 }
18537
18538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192) //Version info
18539 {
18540
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
18541 {
18542 return qe_invalid;
18543 }
18544 99 FFCore.quest_format[vCombos] = section_version;
18545
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
18546 {
18547 return qe_invalid;
18548 }
18549
18550 //section size
18551
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18552 {
18553 return qe_invalid;
18554 }
18555 99 }
18556
18557
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(section_version > 32) //Cleanup time!
18558 {
18559
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&combos_used,f,true))
18560 {
18561 return qe_invalid;
18562 }
18563
2/2
✓ Branch 0 taken 131498 times.
✓ Branch 1 taken 20 times.
131518 for(int32_t i=0; i<combos_used; i++)
18564 {
18565 131498 auto ret = readcombo_loop(f,section_version,temp_combo);
18566
1/2
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
131498 if(ret) return ret;
18567
2/4
✓ Branch 0 taken 131498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131498 times.
131498 if(keepdata==true && i>=start_combo)
18568 131498 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18569 131498 }
18570 20 }
18571 else //Call the old function for all old versions
18572 {
18573 79 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(ret) return ret; //error, end read
18575 }
18576
18577
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(keepdata && false/*section_version < 34*/)
18578 {
18579 for(int32_t i=start_combo; i<combos_used; i++)
18580 {
18581 newcombo& cmb = combobuf[i];
18582 //Do anything to 'cmb' needed for version handling
18583 }
18584 }
18585
18586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
18587 {
18588
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 79 times.
99 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18589 {
18590 20 combobuf[0].walk = 0xF0;
18591 20 combobuf[0].type = 0;
18592 20 combobuf[0].flag = 0;
18593 20 }
18594 99 }
18595
18596 99 setup_combo_animations();
18597 99 setup_combo_animations2();
18598 99 return 0;
18599 99 }
18600
18601 96 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18602 {
18603 //these are here to bypass compiler warnings about unused arguments
18604 96 Header=Header;
18605 96 version=version;
18606 96 build=build;
18607
18608 int32_t dummy;
18609 96 word sversion=0, c_sversion;
18610
18611 //section version info
18612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&sversion,f,true))
18613 {
18614 return qe_invalid;
18615 }
18616
18617 96 FFCore.quest_format[vComboAliases] = sversion;
18618
18619 //al_trace("Combo aliases version %d\n", sversion);
18620
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&c_sversion,f,true))
18621 {
18622 return qe_invalid;
18623 }
18624
18625 //section size
18626
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy,f,true))
18627 {
18628 return qe_invalid;
18629 }
18630
18631 96 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18632
18633
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 74 times.
96 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18634 {
18635 74 max_num_combo_aliases = MAX250COMBOALIASES;
18636 74 }
18637
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18638 {
18639 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18640 }
18641
18642
2/2
✓ Branch 0 taken 331776 times.
✓ Branch 1 taken 96 times.
331872 for(int32_t j=0; j<max_num_combo_aliases; j++)
18643 {
18644 byte width,height,mask,tempcset;
18645 int32_t count;
18646 word tempword;
18647 byte tempbyte;
18648
18649
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_igetw(&tempword,f,true))
18650 {
18651 return qe_invalid;
18652 }
18653
18654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18655 {
18656 331776 combo_aliases[j].combo = tempword;
18657 331776 }
18658
18659
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&tempbyte,f,true))
18660 {
18661 return qe_invalid;
18662 }
18663
18664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18665 {
18666 331776 combo_aliases[j].cset = tempbyte;
18667 331776 }
18668
18669
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&width,f,true))
18670 {
18671 return qe_invalid;
18672 }
18673
18674
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&height,f,true))
18675 {
18676 return qe_invalid;
18677 }
18678
18679
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(!p_getc(&mask,f,true))
18680 {
18681 return qe_invalid;
18682 }
18683
18684 331776 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18685
18686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 if(keepdata)
18687 {
18688
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].combos != NULL)
18689 {
18690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].combos;
18691 331776 }
18692
18693
1/2
✓ Branch 0 taken 331776 times.
✗ Branch 1 not taken.
331776 if(combo_aliases[j].csets != NULL)
18694 {
18695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 331776 times.
331776 delete[] combo_aliases[j].csets;
18696 331776 }
18697
18698 331776 combo_aliases[j].width = width;
18699 331776 combo_aliases[j].height = height;
18700 331776 combo_aliases[j].layermask = mask;
18701 331776 combo_aliases[j].combos = new word[count];
18702 331776 combo_aliases[j].csets = new byte[count];
18703 331776 }
18704
18705
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18706 {
18707
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_igetw(&tempword,f,true))
18708 {
18709 return qe_invalid;
18710 }
18711
18712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18713 {
18714 339765 combo_aliases[j].combos[k] = tempword;
18715 339765 }
18716 339765 }
18717
18718
2/2
✓ Branch 0 taken 339765 times.
✓ Branch 1 taken 331776 times.
671541 for(int32_t k=0; k<count; k++)
18719 {
18720
1/2
✓ Branch 0 taken 339765 times.
✗ Branch 1 not taken.
339765 if(!p_getc(&tempcset,f,true))
18721 {
18722 return qe_invalid;
18723 }
18724
18725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339765 times.
339765 if(keepdata)
18726 {
18727 339765 combo_aliases[j].csets[k] = tempcset;
18728 339765 }
18729 339765 }
18730 331776 }
18731
18732 96 word num_combo_pools = 0;
18733
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 20 times.
96 if(sversion >= 4)
18734 {
18735
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(!p_igetw(&num_combo_pools,f,true))
18736 {
18737 return qe_invalid;
18738 }
18739 20 }
18740
18741
2/2
✓ Branch 0 taken 786432 times.
✓ Branch 1 taken 96 times.
786528 for(combo_pool& pool : combo_pools)
18742 {
18743 786432 pool.clear();
18744 }
18745
18746 96 combo_pool temp_cpool;
18747
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 96 times.
150 for(word cp = 0; cp < num_combo_pools; ++cp)
18748 {
18749 54 int32_t num_combos_in_pool = 0;
18750
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 if(!p_igetl(&num_combos_in_pool,f,true))
18751 {
18752 return qe_invalid;
18753 }
18754
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(num_combos_in_pool < 1) continue; //nothing to read
18755
18756
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 temp_cpool.clear();
18757
18758 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18759
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 54 times.
288 for(auto q = 0; q < num_combos_in_pool; ++q)
18760 {
18761
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetl(&cp_cid,f,true))
18762 {
18763 return qe_invalid;
18764 }
18765
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_getc(&cp_cs,f,true))
18766 {
18767 return qe_invalid;
18768 }
18769
2/4
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234 times.
✗ Branch 3 not taken.
234 if(!p_igetw(&cp_quant,f,true))
18770 {
18771 return qe_invalid;
18772 }
18773
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18774 234 }
18775
18776
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(keepdata)
18777 {
18778
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 combo_pools[cp] = temp_cpool;
18779 54 }
18780 54 }
18781
18782 96 return 0;
18783 96 }
18784
18785 99 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18786 {
18787 //these are here to bypass compiler warnings about unused arguments
18788
18789 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18790 //Capitalized cause it'll save you a headache. -Deedee
18791 99 start_cset=start_cset;
18792 99 max_csets=max_csets;
18793 99 word s_version=0;
18794
18795 miscQdata temp_misc;
18796 99 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18797
18798 byte temp_colordata[48];
18799 char temp_palname[PALNAMESIZE];
18800
18801 int32_t dummy;
18802 word palcycles;
18803
18804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
18805 {
18806 //section version info
18807
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
18808 {
18809 return qe_invalid;
18810 }
18811
18812 99 FFCore.quest_format[vCSets] = s_version;
18813
18814 //al_trace("Color data version %d\n", s_version);
18815
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
18816 {
18817 return qe_invalid;
18818 }
18819
18820 //section size
18821
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
18822 {
18823 return qe_invalid;
18824 }
18825 99 }
18826
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if (s_version < 5)
18827 {
18828
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18829
18830 //finally... section data
18831 77 int32_t q = 0;
18832 77 int32_t p = -15;
18833
2/2
✓ Branch 0 taken 18480 times.
✓ Branch 1 taken 77 times.
18557 for(int32_t i=0; i<oldpdTOTAL; ++i)
18834 {
18835 18480 memset(temp_colordata, 0, 48);
18836
18837
1/2
✓ Branch 0 taken 18480 times.
✗ Branch 1 not taken.
18480 if(!pfread(temp_colordata,48,f,true))
18838 {
18839 return qe_invalid;
18840 }
18841
18842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18480 times.
18480 if(keepdata==true)
18843 {
18844 18480 memcpy(&colordata[q*48], temp_colordata, 48);
18845 18480 }
18846 18480 ++q;
18847
7/8
✓ Branch 0 taken 17248 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 1309 times.
✓ Branch 3 taken 15939 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 154 times.
18480 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18848 {
18849
1/2
✓ Branch 0 taken 1309 times.
✗ Branch 1 not taken.
1309 if (s_version < 5) //Bumping up the size of level palettes
18850 {
18851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1309 times.
1309 if(keepdata==true)
18852 {
18853 1309 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18854 1309 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18855 1309 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18856 1309 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18857 1309 }
18858 1309 q+=4;
18859 1309 }
18860 else
18861 {
18862 for(int m = 0; m < 4; ++m)
18863 {
18864 memset(temp_colordata, 0, 48);
18865 if(!pfread(temp_colordata,48,f,true))
18866 {
18867 return qe_invalid;
18868 }
18869 if(keepdata==true)
18870 {
18871 memcpy(&colordata[q*48], temp_colordata, 48);
18872 }
18873 ++q;
18874 }
18875 }
18876 1309 }
18877 18480 ++p;
18878 18480 }
18879
18880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(RealOldVerion)
18881 {
18882 if(keepdata==true)
18883 {
18884 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18885 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18886 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18887 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18888 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18889 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18890 }
18891 }
18892 else
18893 {
18894 77 memset(temp_colordata, 0, 48);
18895
18896
2/2
✓ Branch 0 taken 241241 times.
✓ Branch 1 taken 77 times.
241318 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18897 {
18898
1/2
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
241241 if(!pfread(temp_colordata,48,f,true))
18899 {
18900 return qe_invalid;
18901 }
18902
18903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241241 times.
241241 if(keepdata==true)
18904 {
18905 241241 memcpy(&colordata[q*48], temp_colordata, 48);
18906 241241 }
18907 241241 ++q;
18908
7/8
✓ Branch 0 taken 241241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18557 times.
✓ Branch 3 taken 222684 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 18403 times.
✓ Branch 6 taken 148 times.
✓ Branch 7 taken 6 times.
241241 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18909 {
18910
1/2
✓ Branch 0 taken 18551 times.
✗ Branch 1 not taken.
18551 if (s_version < 5) //Bumping up the size of level palettes
18911 {
18912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18551 times.
18551 if(keepdata==true)
18913 {
18914 18551 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18915 18551 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18916 18551 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18917 18551 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18918 18551 }
18919 18551 q+=4;
18920 18551 }
18921 else
18922 {
18923 for(int m = 0; m < 4; ++m)
18924 {
18925 memset(temp_colordata, 0, 48);
18926 if(!pfread(temp_colordata,48,f,true))
18927 {
18928 return qe_invalid;
18929 }
18930 if(keepdata==true)
18931 {
18932 memcpy(&colordata[q*48], temp_colordata, 48);
18933 }
18934 ++q;
18935 }
18936 }
18937 18551 }
18938 241241 ++p;
18939 241241 }
18940
18941
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 74 times.
77 if(s_version < 4)
18942 {
18943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(keepdata==true)
18944 {
18945 3 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18946 3 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18947 3 }
18948 3 }
18949 else
18950 {
18951
2/2
✓ Branch 0 taken 246272 times.
✓ Branch 1 taken 74 times.
246346 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18952 {
18953
1/2
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
246272 if(!pfread(temp_colordata,48,f,true))
18954 {
18955 return qe_invalid;
18956 }
18957
18958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246272 times.
246272 if(keepdata==true)
18959 {
18960 246272 memcpy(&colordata[q*48], temp_colordata, 48);
18961 246272 }
18962 246272 ++q;
18963
5/6
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✓ Branch 3 taken 227328 times.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 18796 times.
246272 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18964 {
18965
1/2
✓ Branch 0 taken 18796 times.
✗ Branch 1 not taken.
18796 if (s_version < 5) //Bumping up the size of level palettes
18966 {
18967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18796 times.
18796 if(keepdata==true)
18968 {
18969 18796 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18970 18796 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18971 18796 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18972 18796 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18973 18796 }
18974 18796 q+=4;
18975 18796 }
18976 else
18977 {
18978 for(int m = 0; m < 4; ++m)
18979 {
18980 memset(temp_colordata, 0, 48);
18981 if(!pfread(temp_colordata,48,f,true))
18982 {
18983 return qe_invalid;
18984 }
18985 if(keepdata==true)
18986 {
18987 memcpy(&colordata[q*48], temp_colordata, 48);
18988 }
18989 ++q;
18990 }
18991 }
18992 18796 }
18993 246272 ++p;
18994 246272 }
18995
18996 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18997 }
18998 }
18999 77 }
19000 else
19001 {
19002
2/2
✓ Branch 0 taken 192478 times.
✓ Branch 1 taken 22 times.
192500 for(int32_t i=0; i<pdTOTAL255; ++i)
19003 {
19004 192478 memset(temp_colordata, 0, 48);
19005
19006
1/2
✓ Branch 0 taken 192478 times.
✗ Branch 1 not taken.
192478 if(!pfread(temp_colordata,48,f,true))
19007 {
19008 return qe_invalid;
19009 }
19010
19011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192478 times.
192478 if(keepdata==true)
19012 {
19013 192478 memcpy(&colordata[i*48], temp_colordata, 48);
19014 192478 }
19015 192478 }
19016 }
19017
19018
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)||((version == 0x192)&&(build<76)))
19019 {
19020 if(keepdata==true)
19021 {
19022 init_palnames();
19023 }
19024 }
19025 else
19026 {
19027 99 int32_t palnamestoread = 0;
19028
19029
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 3)
19030 3 palnamestoread = OLDMAXLEVELS;
19031 else
19032 96 palnamestoread = 512;
19033
19034
2/2
✓ Branch 0 taken 49920 times.
✓ Branch 1 taken 99 times.
50019 for(int32_t i=0; i<palnamestoread; ++i)
19035 {
19036 49920 memset(temp_palname, 0, PALNAMESIZE);
19037
19038
1/2
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
49920 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19039 {
19040 return qe_invalid;
19041 }
19042
19043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49920 times.
49920 if(keepdata==true)
19044 {
19045 49920 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19046 49920 }
19047 49920 }
19048
19049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
19050 {
19051
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 99 times.
867 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19052 {
19053 768 memset(palnames[i], 0, PALNAMESIZE);
19054 768 }
19055 99 }
19056 }
19057
19058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
19059 {
19060
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<256; i++)
19061 {
19062
2/2
✓ Branch 0 taken 76032 times.
✓ Branch 1 taken 25344 times.
101376 for(int32_t j=0; j<3; j++)
19063 {
19064 76032 temp_misc.cycles[i][j].first=0;
19065 76032 temp_misc.cycles[i][j].count=0;
19066 76032 temp_misc.cycles[i][j].speed=0;
19067 76032 }
19068 25344 }
19069
19070
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&palcycles,f,true))
19071 {
19072 return qe_invalid;
19073 }
19074
19075
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 99 times.
3322 for(int32_t i=0; i<palcycles; i++)
19076 {
19077
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19078 {
19079
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19080 {
19081 return qe_invalid;
19082 }
19083 9669 }
19084
19085
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19086 {
19087
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19088 {
19089 return qe_invalid;
19090 }
19091 9669 }
19092
19093
2/2
✓ Branch 0 taken 9669 times.
✓ Branch 1 taken 3223 times.
12892 for(int32_t j=0; j<3; j++)
19094 {
19095
1/2
✓ Branch 0 taken 9669 times.
✗ Branch 1 not taken.
9669 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19096 {
19097 return qe_invalid;
19098 }
19099 9669 }
19100 3223 }
19101
19102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19103 {
19104 99 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19105 99 }
19106 99 }
19107
19108 99 return 0;
19109 99 }
19110
19111 99 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19112 {
19113 99 int32_t tiles_used=0;
19114 99 word section_version = 0;
19115 99 word section_cversion = 0;
19116 99 int32_t section_size= 0;
19117 99 byte *temp_tile = new byte[tilesize(tf32Bit)];
19118
19119 //Tile Expansion
19120 //if ( version >= 0x254 && build >= 41 )
19121
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
99 if (version < 0x254 && build < 41)
19122 {
19123 //al_trace("Build was < 41 when reading tiles\n");
19124 77 max_tiles = ZC250MAXTILES;
19125 77 }
19126
19127 //al_trace("Max Tiles: %d\n", max_tiles);
19128
19129
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19130 {
19131 if(keepdata==true)
19132 {
19133 if(!init_tiles(true, Header))
19134 {
19135 al_trace("Unable to initialize tiles\n");
19136 }
19137 }
19138
19139 delete[] temp_tile;
19140 temp_tile=NULL;
19141 return 0;
19142 }
19143 else
19144 {
19145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version > 0x192)
19146 {
19147 //section version info
19148
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
19149 {
19150 delete[] temp_tile;
19151 return qe_invalid;
19152 }
19153
19154 99 FFCore.quest_format[vTiles] = section_version;
19155
19156
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_cversion,f,true))
19157 {
19158 delete[] temp_tile;
19159 return qe_invalid;
19160 }
19161
19162 //section size
19163
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&section_size,f,true))
19164 {
19165 delete[] temp_tile;
19166 return qe_invalid;
19167 }
19168 99 }
19169
19170 //if ( build < 41 )
19171 //{
19172 // tiles_used = ZC250MAXTILES;
19173 //}
19174
19175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(version < 0x174)
19176 {
19177 tiles_used=TILES_PER_PAGE*4;
19178 } //no expanded tile space
19179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 else if(version < 0x191)
19180 {
19181 tiles_used=OLDMAXTILES;
19182 }
19183 else
19184 {
19185 //finally... section data
19186
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
99 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19187 {
19188
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&tiles_used,f,true))
19189 {
19190 delete[] temp_tile;
19191 return qe_invalid;
19192 }
19193 22 }
19194 else
19195 {
19196
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tiles_used,f,true))
19197 {
19198 delete[] temp_tile;
19199 return qe_invalid;
19200 }
19201 }
19202 }
19203
19204
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 tiles_used=zc_min(tiles_used, max_tiles);
19205
19206 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19207 //if ( version < 0x254 && build < 41 )
19208
3/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if ( version < 0x254 || (version == 0x254 && build < 41) )
19209 //if ( build < 41 )
19210 {
19211
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19212 77 }
19213 else //2.55
19214 {
19215
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19216 }
19217
19218 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19219
19220 //al_trace("tiles_used = %d\n", tiles_used);
19221
19222
2/2
✓ Branch 0 taken 2239372 times.
✓ Branch 1 taken 99 times.
2239471 for(int32_t i=0; i<tiles_used; ++i)
19223 {
19224 2239372 byte format=tf4Bit;
19225 2239372 memset(temp_tile, 0, tilesize(tf32Bit));
19226
19227
3/6
✓ Branch 0 taken 34986 times.
✓ Branch 1 taken 2204386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34986 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2239372 if((version>0x211)||((version==0x211)&&(build>4)))
19228 {
19229
1/2
✓ Branch 0 taken 2204386 times.
✗ Branch 1 not taken.
2204386 if(!p_getc(&format,f,true))
19230 {
19231 delete[] temp_tile;
19232 return qe_invalid;
19233 }
19234 2204386 }
19235
4/4
✓ Branch 0 taken 557954 times.
✓ Branch 1 taken 1681418 times.
✓ Branch 2 taken 276608 times.
✓ Branch 3 taken 281346 times.
2239372 if(section_version > 2 && !format)
19236 {
19237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281346 times.
281346 if(keepdata)
19238 {
19239 281346 reset_tile(buf,start_tile+i,tf4Bit);
19240 281346 }
19241 281346 continue;
19242 }
19243
19244
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(!pfread(temp_tile,tilesize(format),f,true))
19245 {
19246 delete[] temp_tile;
19247 return qe_invalid;
19248 }
19249
19250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1958026 times.
1958026 if(keepdata==true)
19251 {
19252 1958026 buf[start_tile+i].format=format;
19253
19254
1/2
✓ Branch 0 taken 1958026 times.
✗ Branch 1 not taken.
1958026 if(buf[start_tile+i].data)
19255 {
19256 1958026 free(buf[start_tile+i].data);
19257 1958026 buf[start_tile+i].data=NULL;
19258 1958026 }
19259
19260 1958026 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19261 1958026 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19262 1958026 }
19263 1958026 }
19264 }
19265
19266
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19267 {
19268 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19269
2/2
✓ Branch 0 taken 11471460 times.
✓ Branch 1 taken 77 times.
11471537 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19270 {
19271
19272 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19273 11471460 reset_tile(buf,q,tf4Bit);
19274
19275
19276 /*
19277
19278 byte tempbyte;
19279 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19280 {
19281 tempbyte=buf[ZC250MAXTILES-1].data[i];
19282 buf[q].data[i] = tempbyte;
19283 }
19284 //int32_t temp = tempbyte=buf[130].data[i];
19285 //buf[q].data = buf[ZC250MAXTILES-1].data;
19286 */
19287 //reset_tile(buf,q,tf4Bit);
19288 11471460 }
19289
19290 77 }
19291
19292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19293 {
19294
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
99 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19295 {
19296
2/2
✓ Branch 0 taken 3747632 times.
✓ Branch 1 taken 77 times.
3747709 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19297 {
19298 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19299 3747632 reset_tile(buf,i,tf4Bit);
19300 3747632 }
19301 77 }
19302 else
19303 {
19304
2/2
✓ Branch 0 taken 3777036 times.
✓ Branch 1 taken 22 times.
3777058 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19305 {
19306 //al_trace("Resetting tiles for build 41+\n");
19307 3777036 reset_tile(buf,i,tf4Bit);
19308 3777036 }
19309 }
19310
19311
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19312 {
19313 if(get_bit(quest_rules,qr_BSZELDA)) //
19314 {
19315 byte tempbyte;
19316 int32_t floattile=wpnsbuf[iwSwim].tile;
19317
19318 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19319 {
19320 tempbyte=buf[23].data[i];
19321 buf[23].data[i]=buf[24].data[i];
19322 buf[24].data[i]=buf[25].data[i];
19323 buf[25].data[i]=buf[26].data[i];
19324 buf[26].data[i]=tempbyte;
19325 }
19326 //swim tiles are out of order, too, but nobody cared? -Z
19327 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19328 {
19329 tempbyte=buf[floattile+11].data[i];
19330 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19331 buf[floattile+12].data[i]=tempbyte;
19332 }
19333 }
19334 }
19335
19336
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19337 {
19338
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19339 {
19340 byte tempbyte;
19341
19342 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19343 {
19344 tempbyte=buf[130].data[i];
19345 buf[130].data[i]=buf[132].data[i];
19346 buf[132].data[i]=tempbyte;
19347
19348 tempbyte=buf[131].data[i];
19349 buf[131].data[i]=buf[133].data[i];
19350 buf[133].data[i]=tempbyte;
19351 }
19352 }
19353 3 }
19354
19355 99 al_trace("Registering blank tiles\n");
19356 99 register_blank_tiles();
19357 99 }
19358
19359 //memset(temp_tile, 0, tilesize(tf32Bit));
19360
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 delete[] temp_tile;
19361 99 temp_tile=NULL;
19362 99 return 0;
19363 99 }
19364
19365 99 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19366 {
19367 99 byte *mf=midi_flags;
19368 int32_t dummy;
19369 word dummy2;
19370 // zcmidi_ temp_midi;
19371 int32_t tunes_to_read;
19372 99 int32_t tune_count=0;
19373 99 word section_version=0;
19374 99 zctune temp;
19375
19376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version < 0x193)
19377 {
19378 // mf=Header->data_flags+ZQ_MIDIS2;
19379 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19380 {
19381 tunes_to_read=MAXCUSTOMMIDIS192b177;
19382 }
19383 else
19384 {
19385 tunes_to_read=MAXCUSTOMTUNES;
19386 }
19387 }
19388 else
19389 {
19390 //section version info
19391
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&section_version,f,true))
19392 {
19393 return qe_invalid;
19394 }
19395
19396 99 FFCore.quest_format[vMIDIs] = section_version;
19397
19398 //al_trace("Tunes version %d\n", section_version);
19399
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy2,f,true))
19400 {
19401 return qe_invalid;
19402 }
19403
19404 //section size
19405
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19406 {
19407 return qe_invalid;
19408 }
19409
19410 //finally... section data
19411
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19412 {
19413 return qe_invalid;
19414 }
19415
19416 99 tunes_to_read=MAXCUSTOMTUNES;
19417 }
19418
19419
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19420 {
19421
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf, i))
19422 {
19423 1629 ++tune_count;
19424 1629 }
19425 24948 }
19426
19427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19428 {
19429 99 reset_tunes(tunes); //reset_midis(midis);
19430 99 }
19431
19432
2/2
✓ Branch 0 taken 24948 times.
✓ Branch 1 taken 99 times.
25047 for(int32_t i=0; i<tunes_to_read; i++)
19433 {
19434 24948 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19435
19436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24948 times.
24948 if(keepdata==true)
19437 {
19438 24948 tunes[i].reset(); // reset_midi(midis+i);
19439 24948 }
19440
19441
2/2
✓ Branch 0 taken 23319 times.
✓ Branch 1 taken 1629 times.
24948 if(get_bit(mf,i))
19442 {
19443
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 4)
19444 {
19445
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19446 {
19447 return qe_invalid;
19448 }
19449 99 }
19450 else
19451 {
19452
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19453 {
19454 return qe_invalid;
19455 }
19456 }
19457
19458
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.start,f,true))
19459 {
19460 return qe_invalid;
19461 }
19462
19463
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_start,f,true))
19464 {
19465 return qe_invalid;
19466 }
19467
19468
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetl(&temp.loop_end,f,true))
19469 {
19470 return qe_invalid;
19471 }
19472
19473
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.loop,f,true))
19474 {
19475 return qe_invalid;
19476 }
19477
19478
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temp.volume,f,true))
19479 {
19480 return qe_invalid;
19481 }
19482
19483
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(Header->zelda_version < 0x193)
19484 {
19485 if(!p_igetl(&dummy,f,true))
19486 {
19487 return qe_invalid;
19488 }
19489 }
19490
19491
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version >= 3)
19492 {
19493
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19494 {
19495 return qe_invalid;
19496 }
19497 1530 }
19498
19499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(keepdata==true)
19500 {
19501 1629 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19502 1629 }
19503
19504
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1530 times.
1629 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19505 {
19506 // old format - a midi is a midi
19507
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19508 {
19509 return qe_invalid;
19510 }
19511
19512 //yes you can do this. Isn't the ? operator awesome? :)
19513
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19514 99 }
19515 else
19516 {
19517 // 'midi' could be midi or nes, gb, ... music
19518
2/4
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
1530 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19519 {
19520 return qe_invalid;
19521 }
19522
19523
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19524
19525
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 switch(temp.format)
19526 {
19527 case MFORMAT_MIDI:
19528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1530 times.
1530 if((ptr->data=read_midi(f, true))==NULL)
19529 {
19530 return qe_invalid;
19531 }
19532
19533 1530 break;
19534
19535 default:
19536 return qe_invalid;
19537 break;
19538 }
19539 }
19540 1629 }
19541 24948 }
19542
19543 99 return 0;
19544 99 }
19545
19546 99 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19547 {
19548 int32_t dummy;
19549 ZCHEATS tempzcheats;
19550 99 char temp_use_cheats=1;
19551 99 memset(&tempzcheats, 0, sizeof(tempzcheats));
19552 99 word s_version = 0;
19553
19554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->zelda_version > 0x192)
19555 {
19556 //section version info
19557
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&s_version,f,true))
19558 {
19559 return qe_invalid;
19560 }
19561
19562 99 FFCore.quest_format[vCheats] = s_version;
19563 //al_trace("Cheats version %d\n", dummy);
19564
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetw(&dummy,f,true))
19565 {
19566 return qe_invalid;
19567 }
19568
19569 //section size
19570
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&dummy,f,true))
19571 {
19572 return qe_invalid;
19573 }
19574
19575 //finally... section data
19576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!p_getc(&temp_use_cheats,f,true))
19577 {
19578 return qe_invalid;
19579 }
19580 99 }
19581
19582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(Header->data_flags[ZQ_CHEATS2])
19583 {
19584
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_igetl(&tempzcheats.flags,f,true))
19585 {
19586 return qe_invalid;
19587 }
19588
19589
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19590 {
19591 return qe_invalid;
19592 }
19593 99 }
19594
19595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata==true)
19596 {
19597 99 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19598 99 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19599 99 }
19600
19601 99 return 0;
19602 99 }
19603
19604 253 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19605 {
19606 int32_t dummy;
19607 253 word s_version=0, s_cversion=0;
19608 byte padding;
19609 word tempw;
19610
19611 253 zinitdata temp_zinit;
19612
19613 // Legacy item properties (now integrated into itemdata)
19614 byte sword_hearts[4];
19615 byte beam_hearts[4];
19616 253 byte beam_percent=0;
19617 word beam_power[4];
19618 253 byte hookshot_length=99;
19619 253 byte hookshot_links=100;
19620 253 byte longshot_length=99;
19621 253 byte longshot_links=100;
19622 253 byte moving_fairy_hearts=3;
19623 253 byte moving_fairy_heart_percent=0;
19624 253 byte stationary_fairy_hearts=3;
19625 253 byte stationary_fairy_heart_percent=0;
19626 253 byte moving_fairy_magic=0;
19627 253 byte moving_fairy_magic_percent=0;
19628 253 byte stationary_fairy_magic=0;
19629 253 byte stationary_fairy_magic_percent=0;
19630 253 byte blue_potion_hearts=100;
19631 253 byte blue_potion_heart_percent=1;
19632 253 byte red_potion_hearts=100;
19633 253 byte red_potion_heart_percent=1;
19634 253 byte blue_potion_magic=100;
19635 253 byte blue_potion_magic_percent=1;
19636 253 byte red_potion_magic=100;
19637 253 byte red_potion_magic_percent=1;
19638
19639
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 154 times.
253 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19640
19641
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version > 0x192)
19642 {
19643 //section version info
19644
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_version,f,true))
19645 {
19646 return qe_invalid;
19647 }
19648
19649 99 FFCore.quest_format[vInitData] = s_version;
19650
19651 //al_trace("Init data version %d\n", s_version);
19652
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&s_cversion,f,true))
19653 {
19654 return qe_invalid;
19655 }
19656
19657 //section size
19658
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&dummy,f,true))
19659 {
19660 return qe_invalid;
19661 }
19662 99 }
19663
19664 /* HIGHLY UNORTHODOX UPDATING THING, by L
19665 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19666 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19667 * changing from 13 to 14.
19668 */
19669
3/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 3 times.
99 if(keepdata && s_version < 14)
19670 3 fixpolsvoice=true;
19671
19672 /* End highly unorthodox updating thing */
19673
19674
5/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 23 times.
99 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19675 23 temp_zinit.jump_hero_layer_threshold=0;
19676
19677
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version >= 10)
19678 {
19679 char temp;
19680
19681 //new-style items
19682
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t j=0; j<256; j++)
19683 {
19684
2/4
✓ Branch 0 taken 24576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24576 times.
24576 if(!p_getc(&temp,f,true))
19685 return qe_invalid;
19686
19687 24576 temp_zinit.items[j] = (temp != 0);
19688 24576 }
19689 96 }
19690
19691
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 55 times.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19692 {
19693 char temp;
19694
19695 //finally... section data
19696
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 55 times.
154 if((Header->zelda_version > 0x192)||
19697 //new only
19698 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19699 {
19700 //OLD-style items... sigh
19701
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 10)
19702 {
19703
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19704 {
19705 return qe_invalid;
19706 }
19707
19708 3 temp_zinit.items[iRaft]=(temp != 0);
19709
19710
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19711 {
19712 return qe_invalid;
19713 }
19714
19715 3 temp_zinit.items[iLadder]=(temp != 0);
19716
19717
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19718 {
19719 return qe_invalid;
19720 }
19721
19722 3 temp_zinit.items[iBook]=(temp != 0);
19723
19724
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19725 {
19726 return qe_invalid;
19727 }
19728
19729 3 temp_zinit.items[iMKey]=(temp!=0);
19730
19731
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19732 {
19733 return qe_invalid;
19734 }
19735
19736 3 temp_zinit.items[iFlippers]=(temp != 0);
19737
19738
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19739 {
19740 return qe_invalid;
19741 }
19742
19743 3 temp_zinit.items[iBoots]=(temp!=0);
19744 3 }
19745 99 }
19746
19747
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 151 times.
154 if(s_version < 10)
19748 {
19749 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19750
19751
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempring,f,true))
19752 {
19753 return qe_invalid;
19754 }
19755
19756
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempsword,f,true))
19757 {
19758 return qe_invalid;
19759 }
19760
19761
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempshield,f,true))
19762 {
19763 return qe_invalid;
19764 }
19765
19766
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwallet,f,true))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbracelet,f,true))
19772 {
19773 return qe_invalid;
19774 }
19775
19776
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempamulet,f,true))
19777 {
19778 return qe_invalid;
19779 }
19780
19781
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbow,f,true))
19782 {
19783 return qe_invalid;
19784 }
19785
19786 //old only
19787
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19788 {
19789 tempring=(tempring)?(1<<(tempring-1)):0;
19790 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19791 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19792 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19793 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19794 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19795 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19796 }
19797
19798 //rings start at level 2... wtf
19799 //account for this -DD
19800 3 tempring <<= 1;
19801
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19802
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19803
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19804
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19805 //bracelet ALSO starts at level 2 :-( -DD
19806 3 tempbracelet<<=1;
19807
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19808
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19809
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19810
19811 //new only
19812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build>173))
19813 {
19814 for(int32_t q=0; q<32; q++)
19815 {
19816 if(!p_getc(&padding,f,true))
19817 {
19818 return qe_invalid;
19819 }
19820 }
19821 }
19822
19823 char tempcandle, tempboomerang, temparrow, tempwhistle;
19824
19825
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempcandle,f,true))
19826 {
19827 return qe_invalid;
19828 }
19829
19830
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempboomerang,f,true))
19831 {
19832 return qe_invalid;
19833 }
19834
19835
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temparrow,f,true))
19836 {
19837 return qe_invalid;
19838 }
19839
19840
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19841 {
19842 return qe_invalid;
19843 }
19844
19845
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19846
19847
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempwhistle,f,true))
19848 {
19849 return qe_invalid;
19850 }
19851
19852 //old only
19853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version == 0x192)&&(Header->build<174))
19854 {
19855 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19856 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19857 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19858 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19859 }
19860
19861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19862
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19863
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19864
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19865 //What about the potion...?
19866
19867 3 }
19868
19869
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 77 times.
154 if(s_version < 29)
19870 {
19871 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19872 //to jab out my eye...
19873
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19874 return qe_invalid;
19875 77 temp_zinit.bombs = padding;
19876
19877
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
19878 return qe_invalid;
19879 77 temp_zinit.super_bombs = padding;
19880 77 }
19881
19882 //Back to more OLD item code
19883
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
154 if(s_version < 10)
19884 {
19885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if((Header->zelda_version > 0x192)||
19886 //new only
19887 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19888 {
19889
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19890 {
19891 return qe_invalid;
19892 }
19893
19894
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19895
19896
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19897 {
19898 return qe_invalid;
19899 }
19900
19901
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19902
19903
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19904 {
19905 return qe_invalid;
19906 }
19907
19908
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19909
19910
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19911 {
19912 return qe_invalid;
19913 }
19914
19915
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19916
19917
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19918 {
19919 return qe_invalid;
19920 }
19921
19922
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19923
19924
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19925 {
19926 return qe_invalid;
19927 }
19928
19929
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19930
19931
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19932 {
19933 return qe_invalid;
19934 }
19935
19936
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19937
19938
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19939 {
19940 return qe_invalid;
19941 }
19942
19943
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19944
19945
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19946 {
19947 return qe_invalid;
19948 }
19949
19950
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19951
19952
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temp,f,true))
19953 {
19954 return qe_invalid;
19955 }
19956
19957
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(Header->zelda_version == 0x192)
19958 {
19959 for(int32_t q=0; q<32; q++)
19960 {
19961 if(!p_getc(&padding,f,true))
19962 {
19963 return qe_invalid;
19964 }
19965 }
19966 }
19967 3 }
19968 3 }
19969
19970 //old only
19971
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<174))
19972 {
19973 byte equipment, items; //bit flags
19974
19975 if(!p_getc(&equipment,f,true))
19976 {
19977 return qe_invalid;
19978 }
19979
19980 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19981 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19982 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19983 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19984 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19985 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19986
19987
19988 if(!p_getc(&items,f,true))
19989 {
19990 return qe_invalid;
19991 }
19992
19993 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19994 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19995 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19996 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19997 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19998 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19999 }
20000
20001 if(!p_getc(&temp_zinit.hc,f,true))
20002 {
20003 return qe_invalid;
20004 }
20005
20006
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
20007 {
20008 byte temphp;
20009
20010
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
20011 {
20012 return qe_invalid;
20013 }
20014
20015 3 temp_zinit.start_heart=temphp;
20016
20017
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&temphp,f,true))
20018 {
20019 return qe_invalid;
20020 }
20021
20022 3 temp_zinit.cont_heart=temphp;
20023 3 }
20024 else
20025 {
20026
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_heart,f,true))
20027 {
20028 return qe_invalid;
20029 }
20030
20031
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20032 {
20033 return qe_invalid;
20034 }
20035 }
20036
20037
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.hcp,f,true))
20038 {
20039 return qe_invalid;
20040 }
20041
20042
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version >= 14)
20043 {
20044
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20045 {
20046 return qe_invalid;
20047 }
20048
20049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version<16) // July 2007
20050 {
20051 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20052 temp_zinit.hcp_per_hc = 0xFF;
20053
20054 //Dispose of legacy rule
20055 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20056 }
20057 96 }
20058
20059
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(s_version < 29)
20060 {
20061
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f,true))
20062 return qe_invalid;
20063 77 temp_zinit.max_bombs = padding;
20064 77 }
20065
20066
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.keys,f,true))
20067 {
20068 return qe_invalid;
20069 }
20070
20071
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetw(&temp_zinit.rupies,f,true))
20072 {
20073 return qe_invalid;
20074 }
20075
20076
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.triforce,f,true))
20077 {
20078 return qe_invalid;
20079 }
20080
20081
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20082 {
20083
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20084 {
20085
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.map[i],f,true))
20086 {
20087 return qe_invalid;
20088 }
20089 6144 }
20090
20091
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20092 {
20093
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.compass[i],f,true))
20094 {
20095 return qe_invalid;
20096 }
20097 6144 }
20098 96 }
20099 else
20100 {
20101
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20102 {
20103
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.map[i],f,true))
20104 {
20105 return qe_invalid;
20106 }
20107 96 }
20108
20109
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20110 {
20111
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
96 if(!p_getc(&temp_zinit.compass[i],f,true))
20112 {
20113 return qe_invalid;
20114 }
20115 96 }
20116 }
20117
20118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version > 0x192)||
20119 //new only
20120 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20121 {
20122
3/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20123 {
20124
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 96 times.
6240 for(int32_t i=0; i<64; i++)
20125 {
20126
2/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6144 times.
6144 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20127 {
20128 return qe_invalid;
20129 }
20130 6144 }
20131 96 }
20132 else
20133 {
20134
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 for(int32_t i=0; i<32; i++)
20135 {
20136
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20137 {
20138 return qe_invalid;
20139 }
20140 96 }
20141 }
20142 99 }
20143
20144
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1584 times.
1683 for(int32_t i=0; i<16; i++)
20145 {
20146
2/4
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1584 times.
1584 if(!p_getc(&temp_zinit.misc[i],f,true))
20147 {
20148 return qe_invalid;
20149 }
20150 1584 }
20151
20152
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 3 times.
111 if(s_version < 15) for(int32_t i=0; i<4; i++)
20153 {
20154
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&sword_hearts[i],f,true))
20155 {
20156 return qe_invalid;
20157 }
20158 15 }
20159
20160
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_map,f,true))
20161 {
20162 return qe_invalid;
20163 }
20164
20165
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.last_screen,f,true))
20166 {
20167 return qe_invalid;
20168 }
20169
20170
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version < 14)
20171 {
20172 byte tempmp;
20173
20174
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
20175 {
20176 return qe_invalid;
20177 }
20178
20179 3 temp_zinit.max_magic=tempmp;
20180
20181
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempmp,f,true))
20182 {
20183 return qe_invalid;
20184 }
20185
20186 3 temp_zinit.magic=tempmp;
20187 3 }
20188 else
20189 {
20190
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_magic,f,true))
20191 {
20192 return qe_invalid;
20193 }
20194
20195
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.magic,f,true))
20196 {
20197 return qe_invalid;
20198 }
20199 }
20200
20201
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20202 {
20203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version < 12)
20204 {
20205 3 temp_zinit.max_magic*=32;
20206 3 temp_zinit.magic*=32;
20207 3 }
20208
20209
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20210 {
20211
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_hearts[i],f,true))
20212 {
20213 return qe_invalid;
20214 }
20215 12 }
20216
20217
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&beam_percent,f,true))
20218 {
20219 return qe_invalid;
20220 }
20221 3 }
20222 else
20223 {
20224
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20225 {
20226 return qe_invalid;
20227 }
20228 }
20229
20230
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20231 {
20232 byte tempbp;
20233
20234
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12 times.
15 for(int32_t i=0; i<4; i++)
20235 {
20236
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
12 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20237 {
20238 return qe_invalid;
20239 }
20240
20241 12 beam_power[i]=tempbp;
20242 12 }
20243
20244
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&hookshot_links,f,true))
20245 {
20246 return qe_invalid;
20247 }
20248
20249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(s_version>6)
20250 {
20251 if(!p_getc(&hookshot_length,f,true))
20252 {
20253 return qe_invalid;
20254 }
20255
20256 if(!p_getc(&longshot_links,f,true))
20257 {
20258 return qe_invalid;
20259 }
20260
20261 if(!p_getc(&longshot_length,f,true))
20262 {
20263 return qe_invalid;
20264 }
20265 }
20266 3 }
20267
20268
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20269 {
20270 return qe_invalid;
20271 }
20272
20273
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20274 {
20275 return qe_invalid;
20276 }
20277
20278
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.subscreen,f,true))
20279 {
20280 return qe_invalid;
20281 }
20282
20283 //old only
20284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20285 {
20286 for(int32_t i=0; i<32; i++)
20287 {
20288 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20289 {
20290 return qe_invalid;
20291 }
20292 }
20293 }
20294
20295
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20296 {
20297
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version <= 10)
20298 {
20299 byte tempbyte;
20300
20301
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!p_getc(&tempbyte,f,true))
20302 {
20303 return qe_invalid;
20304 }
20305
20306 3 temp_zinit.start_dmap = (word)tempbyte;
20307 3 }
20308 else
20309 {
20310
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20311 {
20312 return qe_invalid;
20313 }
20314 }
20315
20316
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20317 {
20318 return qe_invalid;
20319 }
20320 99 }
20321
20322
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 22 times.
99 if(s_version>1 && s_version < 29)
20323 {
20324
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20325 return qe_invalid;
20326 74 temp_zinit.arrows = padding;
20327
20328
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20329 return qe_invalid;
20330 74 temp_zinit.max_arrows = padding;
20331 74 }
20332
20333
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
99 if(s_version>2)
20334 {
20335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version <= 10)
20336 {
20337 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20338 {
20339 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20340 {
20341 return qe_invalid;
20342 }
20343 }
20344 }
20345 else
20346 {
20347
2/2
✓ Branch 0 taken 49152 times.
✓ Branch 1 taken 96 times.
49248 for(int32_t i=0; i<MAXLEVELS; i++)
20348 {
20349
2/4
✓ Branch 0 taken 49152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49152 times.
✗ Branch 3 not taken.
49152 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20350 {
20351 return qe_invalid;
20352 }
20353 49152 }
20354 }
20355 96 }
20356
20357
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>3)
20358 {
20359
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20360 {
20361 return qe_invalid;
20362 }
20363
20364
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20365 {
20366 return qe_invalid;
20367 }
20368
20369
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20370 {
20371 return qe_invalid;
20372 }
20373
20374
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20375 {
20376 return qe_invalid;
20377 }
20378
20379
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20380 {
20381 return qe_invalid;
20382 }
20383
20384
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20385 {
20386 return qe_invalid;
20387 }
20388
20389
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20390 {
20391 return qe_invalid;
20392 }
20393
20394
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20395 {
20396 return qe_invalid;
20397 }
20398
20399
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20400
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20401 96 }
20402
20403
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>4 && s_version<15)
20404 {
20405 if(!p_getc(&moving_fairy_hearts,f,true))
20406 {
20407 return qe_invalid;
20408 }
20409
20410 if(!p_getc(&moving_fairy_heart_percent,f,true))
20411 {
20412 return qe_invalid;
20413 }
20414 }
20415
20416
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>5 && s_version < 10)
20417 {
20418 if(!p_getc(&temp,f,true))
20419 {
20420 return qe_invalid;
20421 }
20422
20423 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20424 }
20425
20426
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
99 if(s_version>6 && s_version<15)
20427 {
20428 if(!p_getc(&stationary_fairy_hearts,f,true))
20429 {
20430 return qe_invalid;
20431 }
20432
20433 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20434 {
20435 return qe_invalid;
20436 }
20437
20438 if(!p_getc(&moving_fairy_magic,f,true))
20439 {
20440 return qe_invalid;
20441 }
20442
20443 if(!p_getc(&moving_fairy_magic_percent,f,true))
20444 {
20445 return qe_invalid;
20446 }
20447
20448 if(!p_getc(&stationary_fairy_magic,f,true))
20449 {
20450 return qe_invalid;
20451 }
20452
20453 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20454 {
20455 return qe_invalid;
20456 }
20457
20458 if(!p_getc(&blue_potion_hearts,f,true))
20459 {
20460 return qe_invalid;
20461 }
20462
20463 if(!p_getc(&blue_potion_heart_percent,f,true))
20464 {
20465 return qe_invalid;
20466 }
20467
20468 if(!p_getc(&red_potion_hearts,f,true))
20469 {
20470 return qe_invalid;
20471 }
20472
20473 if(!p_getc(&red_potion_heart_percent,f,true))
20474 {
20475 return qe_invalid;
20476 }
20477
20478 if(!p_getc(&blue_potion_magic,f,true))
20479 {
20480 return qe_invalid;
20481 }
20482
20483 if(!p_getc(&blue_potion_magic_percent,f,true))
20484 {
20485 return qe_invalid;
20486 }
20487
20488 if(!p_getc(&red_potion_magic,f,true))
20489 {
20490 return qe_invalid;
20491 }
20492
20493 if(!p_getc(&red_potion_magic_percent,f,true))
20494 {
20495 return qe_invalid;
20496 }
20497 }
20498
20499
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>6)
20500 {
20501
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20502 {
20503 return qe_invalid;
20504 }
20505 96 }
20506
20507
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>7)
20508 {
20509
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20510 {
20511 return qe_invalid;
20512 }
20513 96 }
20514
20515
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>8)
20516 {
20517
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20518 {
20519 return qe_invalid;
20520 }
20521
20522
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.max_keys,f,true))
20523 {
20524 return qe_invalid;
20525 }
20526 96 }
20527
20528
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>16)
20529 {
20530
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.gravity,f,true))
20531 {
20532 return qe_invalid;
20533 }
20534
20535
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_igetw(&temp_zinit.terminalv,f,true))
20536 {
20537 return qe_invalid;
20538 }
20539
20540
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_speed,f,true))
20541 {
20542 return qe_invalid;
20543 }
20544
20545
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.transition_type,f,true))
20546 {
20547 return qe_invalid;
20548 }
20549
20550
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20551 {
20552 return qe_invalid;
20553 }
20554 96 }
20555
20556
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version>17)
20557 {
20558
2/4
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
96 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20559 {
20560 return qe_invalid;
20561 }
20562 96 }
20563
20564 //expaned init data for larger values in 2.55
20565
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20566 {
20567
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.bombs,f,true))
20568 {
20569 return qe_invalid;
20570 }
20571
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20572 {
20573 return qe_invalid;
20574 }
20575
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20576 {
20577 return qe_invalid;
20578 }
20579
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20580 {
20581 return qe_invalid;
20582 }
20583
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.arrows,f,true))
20584 {
20585 return qe_invalid;
20586 }
20587
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20588 {
20589 return qe_invalid;
20590 }
20591
20592 22 }
20593
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 20 )
20594 {
20595
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroStep,f,true))
20596 {
20597 return qe_invalid;
20598 }
20599 22 }
20600 else
20601 {
20602 77 temp_zinit.heroStep = 150; //1.5 pixels per frame
20603 }
20604
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if ( s_version >= 21 )
20605 {
20606
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20607 {
20608 return qe_invalid;
20609 }
20610 22 }
20611 else
20612 {
20613 77 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20614 }
20615 //old only
20616
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
99 if((Header->zelda_version == 0x192)&&(Header->build<174))
20617 {
20618 byte items2;
20619
20620 if(!p_getc(&items2,f,true))
20621 {
20622 return qe_invalid;
20623 }
20624
20625 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20626 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20627 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20628 }
20629
20630
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x193)
20631 {
20632 for(int32_t q=0; q<96; q++)
20633 {
20634 if(!p_getc(&padding,f,true))
20635 {
20636 return qe_invalid;
20637 }
20638 }
20639
20640 //new only
20641 if((Header->zelda_version == 0x192)&&(Header->build>173))
20642 {
20643 if(!p_getc(&padding,f,true))
20644 {
20645 return qe_invalid;
20646 }
20647
20648 if(!p_getc(&padding,f,true))
20649 {
20650 return qe_invalid;
20651 }
20652 }
20653 }
20654 99 }
20655
20656
3/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
154 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20657 {
20658 //temp_zinit.shield=i_smallshield;
20659
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
58 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20660
20661
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(sshieldid != -1)
20662 3 temp_zinit.items[sshieldid] = true;
20663 3 }
20664
20665
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20666 {
20667 temp_zinit.hc=3;
20668 temp_zinit.start_heart=3;
20669 temp_zinit.cont_heart=3;
20670 temp_zinit.max_bombs=8;
20671 }
20672
20673
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20674 {
20675 sword_hearts[0]=0;
20676 sword_hearts[1]=5;
20677 sword_hearts[2]=12;
20678 sword_hearts[3]=21;
20679 }
20680
20681
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20682 {
20683 temp_zinit.last_map=0;
20684 temp_zinit.last_screen=0;
20685 }
20686
20687
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20688 {
20689 temp_zinit.max_magic=0;
20690 temp_zinit.magic=0;
20691 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20692 }
20693
20694
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20695 {
20696
20697 for(int32_t x=0; x<4; x++)
20698 {
20699 beam_hearts[x]=100;
20700 }
20701
20702 for(int32_t i=0; i<idBP_MAX; i++)
20703 {
20704 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20705 set_bit(quest_rules,qr_LENSHINTS+i,0);
20706 }
20707
20708 for(int32_t x=0; x<4; x++)
20709 {
20710 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20711 }
20712
20713 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20714 hookshot_links=100;
20715 temp_zinit.msg_more_x=224;
20716 temp_zinit.msg_more_y=64;
20717 }
20718
20719 // Okay, let's put these legacy values into itemsbuf.
20720
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(s_version < 15)
20721
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 768 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
20722 {
20723
11/11
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 738 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
768 switch(i)
20724 {
20725 case iFairyStill:
20726 3 itemsbuf[i].misc1 = stationary_fairy_hearts;
20727 3 itemsbuf[i].misc2 = stationary_fairy_magic;
20728 3 itemsbuf[i].misc3 = 0;
20729 3 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20730 3 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20731 3 break;
20732
20733 case iFairyMoving:
20734 3 itemsbuf[i].misc1 = moving_fairy_hearts;
20735 3 itemsbuf[i].misc2 = moving_fairy_magic;
20736 3 itemsbuf[i].misc3 = 50;
20737 3 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20738 3 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20739 3 break;
20740
20741 case iRPotion:
20742 3 itemsbuf[i].misc1 = red_potion_hearts;
20743 3 itemsbuf[i].misc2 = red_potion_magic;
20744 3 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20745 3 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20746 3 break;
20747
20748 case iBPotion:
20749 3 itemsbuf[i].misc1 = blue_potion_hearts;
20750 3 itemsbuf[i].misc2 = blue_potion_magic;
20751 3 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20752 3 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20753 3 break;
20754
20755 case iSword:
20756 3 itemsbuf[i].pickup_hearts = sword_hearts[0];
20757 3 itemsbuf[i].misc1 = beam_hearts[0];
20758 3 itemsbuf[i].misc2 = beam_power[0];
20759 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20760
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20761 3 break;
20762
20763 case iWSword:
20764 3 itemsbuf[i].pickup_hearts = sword_hearts[1];
20765 3 itemsbuf[i].misc1 = beam_hearts[1];
20766 3 itemsbuf[i].misc2 = beam_power[1];
20767
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20768 3 break;
20769
20770 case iMSword:
20771 3 itemsbuf[i].pickup_hearts = sword_hearts[2];
20772 3 itemsbuf[i].misc1 = beam_hearts[2];
20773 3 itemsbuf[i].misc2 = beam_power[2];
20774
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20775 3 break;
20776
20777 case iXSword:
20778 3 itemsbuf[i].pickup_hearts = sword_hearts[3];
20779 3 itemsbuf[i].misc1 = beam_hearts[3];
20780 3 itemsbuf[i].misc2 = beam_power[3];
20781
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20782 3 break;
20783
20784 case iHookshot:
20785 3 itemsbuf[i].misc1 = hookshot_length;
20786 3 itemsbuf[i].misc2 = hookshot_links;
20787 3 break;
20788
20789 case iLongshot:
20790 3 itemsbuf[i].misc1 = longshot_length;
20791 3 itemsbuf[i].misc2 = longshot_links;
20792 3 break;
20793 }
20794 771 }
20795
20796
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20797 {
20798 //was new subscreen rule
20799 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20800 set_bit(quest_rules,qr_FREEFORM,0);
20801 }
20802
20803
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20804 {
20805 temp_zinit.start_dmap=0;
20806 }
20807
20808
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20809 {
20810 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20811 }
20812
20813
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
99 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20814 {
20815 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20816 temp_zinit.max_rupees=999;
20817 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20818 }
20819
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20820 {
20821 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20822 temp_zinit.max_bombs = 8;
20823 }
20824 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20825 //time to ensure that we port all new values properly:
20826
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 3 times.
99 if(Header->zelda_version < 0x250)
20827 {
20828
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20829 3 }
20830
20831
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 21)
20832 {
20833
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20834 {
20835 return qe_invalid;
20836 }
20837
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20838 {
20839 return qe_invalid;
20840 }
20841
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20842 {
20843 return qe_invalid;
20844 }
20845
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20846 {
20847 return qe_invalid;
20848 }
20849 22 }
20850 else
20851 {
20852 77 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20853 77 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20854 77 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20855 77 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20856 }
20857
20858
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 22)
20859 {
20860
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20861 {
20862
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20863 {
20864 return qe_invalid;
20865 }
20866 550 }
20867
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 22 times.
572 for(int32_t q = 0; q < 25; ++q)
20868 {
20869
2/4
✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 550 times.
550 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20870 {
20871 return qe_invalid;
20872 }
20873 550 }
20874 22 }
20875 else
20876 {
20877
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 77 times.
2002 for(int32_t q = 0; q < 25; ++q)
20878 {
20879 1925 temp_zinit.scrcnt[q] = 0;
20880 1925 temp_zinit.scrmaxcnt[q] = 0;
20881 1925 }
20882 }
20883
20884
20885
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 23)
20886 {
20887
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_type,f,true))
20888 {
20889 return qe_invalid;
20890 }
20891
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_arg,f,true))
20892 {
20893 return qe_invalid;
20894 }
20895
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.dither_percent,f,true))
20896 {
20897 return qe_invalid;
20898 }
20899
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20900 {
20901 return qe_invalid;
20902 }
20903
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20904 {
20905 return qe_invalid;
20906 }
20907 22 }
20908 else
20909 {
20910 77 temp_zinit.dither_type = 0;
20911 77 temp_zinit.dither_arg = 0;
20912 77 temp_zinit.dither_percent = 20;
20913 77 temp_zinit.def_lightrad = 24;
20914 77 temp_zinit.transdark_percent = 0;
20915 }
20916
20917
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 24)
20918 {
20919
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.darkcol,f,true))
20920 {
20921 return qe_invalid;
20922 }
20923 22 }
20924 else
20925 {
20926 77 temp_zinit.darkcol = BLACK;
20927 }
20928
20929
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 25)
20930 {
20931
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.gravity2,f,true))
20932 {
20933 return qe_invalid;
20934 }
20935
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20936 {
20937 return qe_invalid;
20938 }
20939 22 }
20940 else
20941 {
20942 77 temp_zinit.gravity2 = temp_zinit.gravity*100;
20943 77 temp_zinit.swimgravity = 5;
20944 }
20945
20946
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 26)
20947 {
20948
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20949 {
20950 return qe_invalid;
20951 }
20952
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20953 {
20954 return qe_invalid;
20955 }
20956
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20957 {
20958 return qe_invalid;
20959 }
20960 22 }
20961 else
20962 {
20963 77 temp_zinit.heroSideswimUpStep = 150;
20964 77 temp_zinit.heroSideswimSideStep = 100;
20965 77 temp_zinit.heroSideswimDownStep = 75;
20966 }
20967
20968
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 27)
20969 {
20970
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20971 {
20972 return qe_invalid;
20973 }
20974 22 }
20975 else
20976 {
20977 77 temp_zinit.exitWaterJump = 0;
20978 }
20979
20980
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 29)
20981 {
20982
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20983 {
20984 return qe_invalid;
20985 }
20986 22 }
20987 else
20988 {
20989 77 temp_zinit.bunny_ltm = 0;
20990 }
20991
20992
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 30)
20993 {
20994
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20995 {
20996 return qe_invalid;
20997 }
20998 22 }
20999 else
21000 {
21001 77 temp_zinit.switchhookstyle = 1;
21002 }
21003
21004
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 77 times.
99 if(s_version > 31)
21005 {
21006
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21007 {
21008 return qe_invalid;
21009 }
21010 22 }
21011 else
21012 {
21013
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21014
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21015 }
21016
21017
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_zinit.clear_genscript();
21018
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 86 times.
99 if(s_version > 32)
21019 {
21020 13 word numgenscript = 0;
21021
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&numgenscript,f,true))
21022 return qe_invalid;
21023
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 for(auto q = 1; q < numgenscript; ++q)
21024 {
21025
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21026 return qe_invalid;
21027
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21028 continue;
21029 1 temp_zinit.gen_doscript[q] = padding&1;
21030
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21031 return qe_invalid;
21032
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21033 return qe_invalid;
21034
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21035
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21036 return qe_invalid;
21037
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21038 return qe_invalid;
21039
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21040 return qe_invalid;
21041
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21042 return qe_invalid;
21043 1 }
21044 13 }
21045
21046
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(keepdata==true)
21047 {
21048
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 zinit = temp_zinit;
21049
21050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(zinit.heroAnimationStyle==las_zelda3slow)
21051 {
21052 hero_animation_speed=2;
21053 }
21054 else
21055 {
21056 99 hero_animation_speed=1;
21057 }
21058 99 }
21059
21060 99 return 0;
21061 407 }
21062
21063 /*
21064 void setupitemdropsets()
21065 {
21066 for(int32_t i=0; i<isMAX; i++)
21067 {
21068 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21069 }
21070 }
21071 */
21072
21073 96 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21074 {
21075 96 build=build; // here to prevent compiler warnings
21076 dword dummy_dword;
21077 96 word item_drop_sets_to_read=0;
21078 item_drop_object tempitemdrop;
21079 96 word s_version=0, s_cversion=0;
21080
21081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(keepdata)
21082 {
21083
2/2
✓ Branch 0 taken 24576 times.
✓ Branch 1 taken 96 times.
24672 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21084 {
21085 24576 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21086 24576 }
21087 96 }
21088
21089
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(version > 0x192)
21090 {
21091 96 item_drop_sets_to_read=0;
21092
21093 //section version info
21094
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_version,f,true))
21095 {
21096 return qe_invalid;
21097 }
21098
21099 96 FFCore.quest_format[vItemDropsets] = s_version;
21100
21101 //al_trace("Item drop sets version %d\n", s_version);
21102
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
21103 {
21104 return qe_invalid;
21105 }
21106
21107 //section size
21108
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
21109 {
21110 return qe_invalid;
21111 }
21112
21113 //finally... section data
21114
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&item_drop_sets_to_read,f,true))
21115 {
21116 return qe_invalid;
21117 }
21118 96 }
21119 else
21120 {
21121 if(keepdata==true)
21122 {
21123 init_item_drop_sets();
21124 }
21125 }
21126
21127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(s_version>=1)
21128 {
21129
2/2
✓ Branch 0 taken 1844 times.
✓ Branch 1 taken 96 times.
1940 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21130 {
21131
1/2
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
1844 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21132 {
21133 return qe_invalid;
21134 }
21135
21136
2/2
✓ Branch 0 taken 18440 times.
✓ Branch 1 taken 1844 times.
20284 for(int32_t j=0; j<10; ++j)
21137 {
21138
1/2
✓ Branch 0 taken 18440 times.
✗ Branch 1 not taken.
18440 if(!p_igetw(&tempitemdrop.item[j],f,true))
21139 {
21140 return qe_invalid;
21141 }
21142 18440 }
21143
21144
2/2
✓ Branch 0 taken 20284 times.
✓ Branch 1 taken 1844 times.
22128 for(int32_t j=0; j<11; ++j)
21145 {
21146
1/2
✓ Branch 0 taken 20284 times.
✗ Branch 1 not taken.
20284 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21147 {
21148 return qe_invalid;
21149 }
21150 20284 }
21151
21152 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21153 // overrides the quest's set #12.
21154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2 && i==12)
21155 continue;
21156
21157 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21158
1/4
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1844 if(s_version<2) for(int32_t j=0; j<10; ++j)
21159 {
21160 int32_t it = tempitemdrop.item[j];
21161
21162 if((itemsbuf[it].family == itype_rupee
21163 && ((itemsbuf[it].amount)&0xFFF) == 10)
21164 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21165 {
21166 tempitemdrop.chance[j+1]=0;
21167 }
21168 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21169 {
21170 tempitemdrop.chance[j+1]=0;
21171 }
21172
21173 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21174 if(itemsbuf[it].family == itype_misc)
21175 {
21176 // If a non-gameplay item was selected, then item drop was aborted.
21177 // Reflect this by increasing the 'Nothing' chance accordingly.
21178 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21179 tempitemdrop.chance[j+1]=0;
21180 }
21181 }
21182
21183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1844 times.
1844 if(keepdata)
21184 {
21185 1844 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21186 1844 }
21187 1844 }
21188 96 }
21189
21190 96 return 0;
21191 96 }
21192
21193 96 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21194 {
21195 int32_t temp_num;
21196 dword dummy_dword;
21197 word num_favorite_combos;
21198 word num_favorite_combo_aliases;
21199 96 word s_version=0, s_cversion=0;
21200
21201 //section version info
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_igetw(&s_version,f,true))
21203 {
21204 return qe_invalid;
21205 }
21206
21207 96 FFCore.quest_format[vFavourites] = s_version;
21208
21209
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&s_cversion,f,true))
21210 {
21211 return qe_invalid;
21212 }
21213
21214 //section size
21215
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetl(&dummy_dword,f,true))
21216 {
21217 return qe_invalid;
21218 }
21219
21220 //finally... section data
21221
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combos,f,true))
21222 {
21223 return qe_invalid;
21224 }
21225
21226
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combos; i++)
21227 {
21228
1/2
✓ Branch 0 taken 9600 times.
✗ Branch 1 not taken.
9600 if(!p_igetl(&temp_num,f,true))
21229 {
21230 return qe_invalid;
21231 }
21232
21233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21234 {
21235 9600 favorite_combos[i]=temp_num;
21236 9600 }
21237 9600 }
21238
21239
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21240 {
21241 return qe_invalid;
21242 }
21243
21244
2/2
✓ Branch 0 taken 9600 times.
✓ Branch 1 taken 96 times.
9696 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21245 {
21246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(!p_igetl(&temp_num,f,true))
21247 {
21248 return qe_invalid;
21249 }
21250
21251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9600 times.
9600 if(keepdata)
21252 {
21253 9600 favorite_comboaliases[i]=temp_num;
21254 9600 }
21255 9600 }
21256
21257 96 return 0;
21258 96 }
21259
21260 /*
21261 switch (ret) {
21262 case 0:
21263 break;
21264
21265 case qe_invalid:
21266 goto invalid;
21267 break;
21268 default:
21269 pack_fclose(f);
21270 if(!oldquest)
21271 delete_file(tmpfilename);
21272 return ret;
21273 break;
21274 }
21275 */
21276
21277 const char *skip_text[skip_max]=
21278 {
21279 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21280 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21281 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21282 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21283 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21284 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21285 "skip_favorites"
21286 };
21287
21288
21289 void port250QuestRules(){
21290
21291 portCandleRules(); //Candle
21292 portBombRules();
21293
21294 }
21295
21296 void portCandleRules()
21297 {
21298 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21299 //itemdata itemsbuf;
21300 for ( int32_t q = 0; q < MAXITEMS; q++ )
21301 {
21302 if ( itemsbuf[q].family == itype_candle )
21303 {
21304 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21305 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21306 }
21307 }
21308 }
21309
21310 void portBombRules()
21311 {
21312 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21313 //itemdata itemsbuf;
21314 for ( int32_t q = 0; q < MAXITEMS; q++ )
21315 {
21316 if ( itemsbuf[q].family == itype_bomb )
21317 {
21318 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21319 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21320 }
21321 }
21322
21323 }
21324
21325 //Internal function for loadquest wrapper
21326 99 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21327 {
21328 99 DMapEditorLastMaptileUsed = 0;
21329 99 combosread=false;
21330 99 mapsread=false;
21331 99 fixffcs=false;
21332
21333
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21334 {
21335 keepall=false;
21336 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21337 }
21338
21339 // show_progress=true;
21340 char tmpfilename[L_tmpnam];
21341 99 temp_name(tmpfilename);
21342 // char percent_done[30];
21343 99 bool catchup=false;
21344 byte tempbyte;
21345 99 word old_map_count=map_count;
21346
21347 99 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21348 99 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21349 99 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21350
21351
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_rules))
21352 {
21353 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21354 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21355 }
21356
21357 99 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21358 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21359
21360
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall==false||get_bit(skip_flags, skip_midis))
21361 {
21362 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21363 }
21364
21365
21366
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21367 {
21368 99 zScript.clear();
21369 99 globalmap.clear();
21370 99 genericmap.clear();
21371 99 ffcmap.clear();
21372 99 itemmap.clear();
21373 99 npcmap.clear();
21374 99 ewpnmap.clear();
21375 99 lwpnmap.clear();
21376 99 playermap.clear();
21377 99 dmapmap.clear();
21378 99 screenmap.clear();
21379 99 itemspritemap.clear();
21380 99 comboscriptmap.clear();
21381
21382
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21383 {
21384 50589 ffcmap[i].clear();
21385 50589 }
21386
21387 99 globalmap[0].slotname = "Slot 1:";
21388 99 globalmap[0].scriptname = "~Init";
21389 99 globalmap[0].update();
21390
21391
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 99 times.
792 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21392 {
21393 693 globalmap[i].clear();
21394 693 }
21395
21396
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21397 {
21398 25245 itemmap[i].clear();
21399 25245 }
21400
21401 //new script types -- prevent carrying over to a quest that you load after reading them
21402 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21403
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21404 {
21405 25245 npcmap[i].clear();
21406 25245 }
21407
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21408 {
21409 25245 lwpnmap[i].clear();
21410 25245 }
21411
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21412 {
21413 25245 ewpnmap[i].clear();
21414 25245 }
21415
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 99 times.
495 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21416 {
21417 396 playermap[i].clear();
21418 396 }
21419
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21420 {
21421 25245 dmapmap[i].clear();
21422 25245 }
21423
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21424 {
21425 25245 screenmap[i].clear();
21426 25245 }
21427
2/2
✓ Branch 0 taken 25245 times.
✓ Branch 1 taken 99 times.
25344 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21428 {
21429 25245 itemspritemap[i].clear();
21430 25245 }
21431
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21432 {
21433 50589 comboscriptmap[i].clear();
21434 50589 }
21435
2/2
✓ Branch 0 taken 50589 times.
✓ Branch 1 taken 99 times.
50688 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21436 {
21437 50589 genericmap[i].clear();
21438 50589 }
21439
21440 99 reset_scripts();
21441 99 }
21442
21443 zquestheader tempheader;
21444 99 memset(&tempheader, 0, sizeof(zquestheader));
21445 99 zinfo tempzi;
21446 99 tempzi.clear();
21447 99 load_tmp_zi = &tempzi;
21448
21449 // oldquest flag is set when an unencrypted qst file is suspected.
21450 99 bool oldquest = false;
21451 99 int32_t open_error=0;
21452 char deletefilename[1024];
21453 99 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21454
21455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!f)
21456 return open_error;
21457 char zinfofilename[2048];
21458 99 replace_extension(zinfofilename, filename, "zinfo", 2047);
21459 99 int32_t ret=0;
21460
21461 //header
21462 99 box_out("Reading Header...");
21463 99 ret=readheader(f, &tempheader, true, printmetadata);
21464
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21465 99 box_out("okay.");
21466 99 box_eol();
21467
21468
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 22 times.
99 if(read_zinfo)
21469 {
21470 22 box_out("Reading ZInfo - ");
21471
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 box_out(read_ext_zinfo ? "External..." : "Internal...");
21472
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 21 times.
22 if(read_ext_zinfo)
21473 {
21474 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21475 1 ret=readzinfo(inf, tempzi, tempheader);
21476
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21477
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21478 1 }
21479 else
21480 {
21481 21 ret=readzinfo(f, tempzi, tempheader);
21482
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
21 checkstatus(ret);
21483 }
21484 22 box_out("okay.");
21485 22 box_eol();
21486 22 }
21487
21488
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(tempheader.zelda_version>=0x193)
21489 {
21490 dword section_id;
21491
21492 //section id
21493
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_mgetl(&section_id,f,true))
21494 {
21495 return qe_invalid;
21496 }
21497
21498
2/2
✓ Branch 0 taken 2349 times.
✓ Branch 1 taken 99 times.
2448 while(!pack_feof(f))
21499 {
21500
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 99 times.
✓ Branch 3 taken 99 times.
✓ Branch 4 taken 99 times.
✓ Branch 5 taken 99 times.
✓ Branch 6 taken 96 times.
✓ Branch 7 taken 99 times.
✓ Branch 8 taken 99 times.
✓ Branch 9 taken 99 times.
✓ Branch 10 taken 99 times.
✓ Branch 11 taken 99 times.
✓ Branch 12 taken 99 times.
✓ Branch 13 taken 96 times.
✓ Branch 14 taken 96 times.
✓ Branch 15 taken 99 times.
✓ Branch 16 taken 99 times.
✓ Branch 17 taken 96 times.
✓ Branch 18 taken 96 times.
✓ Branch 19 taken 96 times.
✓ Branch 20 taken 96 times.
✓ Branch 21 taken 99 times.
✓ Branch 22 taken 99 times.
✓ Branch 23 taken 96 times.
✓ Branch 24 taken 96 times.
2349 switch(section_id)
21501 {
21502 case ID_RULES:
21503
21504 //rules
21505
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21506 {
21507 box_out("found.");
21508 box_eol();
21509 catchup=false;
21510 }
21511
21512 99 box_out("Reading Rules...");
21513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21514
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21515 99 box_out("okay.");
21516 99 box_eol();
21517 99 break;
21518
21519 case ID_STRINGS:
21520
21521 //strings
21522
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21523 {
21524 box_out("found.");
21525 box_eol();
21526 catchup=false;
21527 }
21528
21529 99 box_out("Reading Strings...");
21530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21531
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21532 99 box_out("okay.");
21533 99 box_eol();
21534 99 break;
21535
21536 case ID_MISC:
21537
21538 //misc data
21539
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21540 {
21541 box_out("found.");
21542 box_eol();
21543 catchup=false;
21544 }
21545
21546 99 box_out("Reading Misc. Data...");
21547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21548
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21549 99 box_out("okay.");
21550 99 box_eol();
21551 99 break;
21552
21553 case ID_TILES:
21554
21555 //tiles
21556
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21557 {
21558 box_out("found.");
21559 box_eol();
21560 catchup=false;
21561 }
21562
21563 99 box_out("Reading Tiles...");
21564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21565
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21566 99 box_out("okay.");
21567 99 box_eol();
21568 99 break;
21569
21570 case ID_COMBOS:
21571
21572 //combos
21573
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21574 {
21575 box_out("found.");
21576 box_eol();
21577 catchup=false;
21578 }
21579
21580 99 box_out("Reading Combos...");
21581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21582 99 combosread=true;
21583
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21584 99 box_out("okay.");
21585 99 box_eol();
21586 99 break;
21587
21588 case ID_COMBOALIASES:
21589
21590 //combo aliases
21591
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21592 {
21593 box_out("found.");
21594 box_eol();
21595 catchup=false;
21596 }
21597
21598 96 box_out("Reading Combo Aliases...");
21599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21600
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21601 96 box_out("okay.");
21602 96 box_eol();
21603 96 break;
21604
21605 case ID_CSETS:
21606
21607 //color data
21608
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21609 {
21610 box_out("found.");
21611 box_eol();
21612 catchup=false;
21613 }
21614
21615 99 box_out("Reading Color Data...");
21616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21617
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21618 99 box_out("okay.");
21619 99 box_eol();
21620 99 break;
21621
21622 case ID_MAPS:
21623
21624 //maps
21625
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21626 {
21627 box_out("found.");
21628 box_eol();
21629 catchup=false;
21630 }
21631
21632 99 box_out("Reading Maps...");
21633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21634 99 mapsread=true;
21635
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21636 99 box_out("okay.");
21637 99 box_eol();
21638 99 break;
21639
21640 case ID_DMAPS:
21641
21642 //dmaps
21643
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21644 {
21645 box_out("found.");
21646 box_eol();
21647 catchup=false;
21648 }
21649
21650 99 box_out("Reading DMaps...");
21651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21652
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21653 99 box_out("okay.");
21654 99 box_eol();
21655 99 break;
21656
21657 case ID_DOORS:
21658
21659 //door combo sets
21660
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21661 {
21662 box_out("found.");
21663 box_eol();
21664 catchup=false;
21665 }
21666
21667 99 box_out("Reading Doors...");
21668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21669
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21670 99 box_out("okay.");
21671 99 box_eol();
21672 99 break;
21673
21674 case ID_ITEMS:
21675
21676 //items
21677
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21678 {
21679 box_out("found.");
21680 box_eol();
21681 catchup=false;
21682 }
21683
21684 99 box_out("Reading Items...");
21685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21686
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21687
21688 99 box_out("okay.");
21689 99 box_eol();
21690 99 break;
21691
21692 case ID_WEAPONS:
21693
21694 //weapons
21695
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21696 {
21697 box_out("found.");
21698 box_eol();
21699 catchup=false;
21700 }
21701
21702 99 box_out("Reading Weapons...");
21703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21704
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21705 99 box_out("okay.");
21706 99 box_eol();
21707 99 break;
21708
21709 case ID_COLORS:
21710
21711 //misc. colors
21712
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21713 {
21714 box_out("found.");
21715 box_eol();
21716 catchup=false;
21717 }
21718
21719 96 box_out("Reading Misc. Colors...");
21720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21721
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21722 96 box_out("okay.");
21723 96 box_eol();
21724 96 break;
21725
21726 case ID_ICONS:
21727
21728 //game icons
21729
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21730 {
21731 box_out("found.");
21732 box_eol();
21733 catchup=false;
21734 }
21735
21736 96 box_out("Reading Game Icons...");
21737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21738
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21739 96 box_out("okay.");
21740 96 box_eol();
21741 96 break;
21742
21743 case ID_INITDATA:
21744
21745 //initialization data
21746
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21747 {
21748 box_out("found.");
21749 box_eol();
21750 catchup=false;
21751 }
21752
21753 99 box_out("Reading Init. Data...");
21754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21755
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21756 99 box_out("okay.");
21757 99 box_eol();
21758
21759
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21760 {
21761
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 16 times.
99 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21762 {
21763 16 setupsubscreens();
21764
21765
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<MAXDMAPS; ++i)
21766 {
21767 8192 int32_t type=DMaps[i].type&dmfTYPE;
21768
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8131 times.
8192 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21769 8192 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21770 8192 }
21771 16 }
21772 99 }
21773
21774
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_sfx))
21775 {
21776 99 setupsfx();
21777 99 }
21778
21779
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21780 {
21781 99 init_item_drop_sets();
21782 99 }
21783
21784
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_favorites))
21785 {
21786 99 init_favorites();
21787 99 }
21788
21789 99 break;
21790
21791 case ID_GUYS:
21792
21793 //guys
21794
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21795 {
21796 box_out("found.");
21797 box_eol();
21798 catchup=false;
21799 }
21800
21801 99 box_out("Reading Custom Guy Data...");
21802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21803
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21804 99 box_out("okay.");
21805 99 box_eol();
21806 99 break;
21807
21808 case ID_HEROSPRITES:
21809
21810 //player sprites
21811
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21812 {
21813 box_out("found.");
21814 box_eol();
21815 catchup=false;
21816 }
21817
21818 96 box_out("Reading Custom Player Sprite Data...");
21819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21820
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21821 96 box_out("okay.");
21822 96 box_eol();
21823 96 break;
21824
21825 case ID_SUBSCREEN:
21826
21827 //custom subscreens
21828
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21829 {
21830 box_out("found.");
21831 box_eol();
21832 catchup=false;
21833 }
21834
21835 96 box_out("Reading Custom Subscreen Data...");
21836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21837
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21838 96 box_out("okay.");
21839 96 box_eol();
21840 96 break;
21841
21842 case ID_FFSCRIPT:
21843
21844 //Freeform combo scripts
21845
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21846 {
21847 box_out("found.");
21848 box_eol();
21849 catchup=false;
21850 }
21851
21852 96 box_out("Reading FF Script Data...");
21853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21854
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21855 96 box_out("okay.");
21856 96 box_eol();
21857 96 break;
21858
21859 case ID_SFX:
21860
21861 //SFX data
21862
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21863 {
21864 box_out("found.");
21865 box_eol();
21866 catchup=false;
21867 }
21868
21869 96 box_out("Reading SFX Data...");
21870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21871
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21872 96 box_out("okay.");
21873 96 box_eol();
21874 96 break;
21875
21876 case ID_MIDIS:
21877
21878 //midis
21879
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21880 {
21881 box_out("found.");
21882 box_eol();
21883 catchup=false;
21884 }
21885
21886 99 box_out("Reading Tunes...");
21887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21888
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21889 99 box_out("okay.");
21890 99 box_eol();
21891 99 break;
21892
21893 case ID_CHEATS:
21894
21895 //cheat codes
21896
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(catchup)
21897 {
21898 box_out("found.");
21899 box_eol();
21900 catchup=false;
21901 }
21902
21903 99 box_out("Reading Cheat Codes...");
21904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21905
1/5
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
99 checkstatus(ret);
21906 99 box_out("okay.");
21907 99 box_eol();
21908 99 break;
21909
21910 case ID_ITEMDROPSETS:
21911
21912 //item drop sets
21913
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21914 {
21915 box_out("found.");
21916 box_eol();
21917 catchup=false;
21918 }
21919
21920 96 box_out("Reading Item Drop Sets...");
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21922
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21923 96 box_out("okay.");
21924 96 box_eol();
21925 96 break;
21926
21927 case ID_FAVORITES:
21928
21929 //favorite combos and combo aliases
21930
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(catchup)
21931 {
21932 box_out("found.");
21933 box_eol();
21934 catchup=false;
21935 }
21936
21937 96 box_out("Reading Favorite Combos...");
21938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21939
1/5
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
96 checkstatus(ret);
21940 96 box_out("okay.");
21941 96 box_eol();
21942 96 break;
21943
21944 default:
21945 if(!catchup)
21946 {
21947 box_out("Bad token! Searching...");
21948 box_eol();
21949 }
21950
21951 catchup=true;
21952 break;
21953 }
21954
21955
21956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2349 times.
2349 if(catchup)
21957 {
21958 //section id
21959 section_id=(section_id<<8);
21960
21961 if(!p_getc(&tempbyte,f,true))
21962 {
21963 return qe_invalid;
21964 }
21965
21966 section_id+=tempbyte;
21967 }
21968
21969 else
21970 {
21971 //section id
21972
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2250 times.
2349 if(!pack_feof(f))
21973 {
21974
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if(!p_mgetl(&section_id,f,true))
21975 {
21976 return qe_invalid;
21977 }
21978 2250 }
21979 }
21980 }
21981 99 }
21982 else
21983 {
21984 //rules
21985 box_out("Reading Rules...");
21986 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21987 checkstatus(ret);
21988 box_out("okay.");
21989 box_eol();
21990
21991 //strings
21992 box_out("Reading Strings...");
21993 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21994 checkstatus(ret);
21995 box_out("okay.");
21996 box_eol();
21997
21998 //door combo sets
21999 box_out("Reading Doors...");
22000 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22001 checkstatus(ret);
22002 box_out("okay.");
22003 box_eol();
22004
22005 //dmaps
22006 box_out("Reading DMaps...");
22007 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22008 checkstatus(ret);
22009 box_out("okay.");
22010 box_eol();
22011
22012 // misc data
22013 box_out("Reading Misc. Data...");
22014 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22015 checkstatus(ret);
22016 box_out("okay.");
22017 box_eol();
22018
22019 //items
22020 box_out("Reading Items...");
22021 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22022 checkstatus(ret);
22023 box_out("okay.");
22024 box_eol();
22025
22026 //weapons
22027 box_out("Reading Weapons...");
22028 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22029 checkstatus(ret);
22030 box_out("okay.");
22031 box_eol();
22032
22033 //guys
22034 box_out("Reading Custom Guy Data...");
22035 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22036 checkstatus(ret);
22037 box_out("okay.");
22038 box_eol();
22039
22040 //maps
22041 box_out("Reading Maps...");
22042 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22043 mapsread=true;
22044 checkstatus(ret);
22045 box_out("okay.");
22046 box_eol();
22047
22048 //combos
22049 box_out("Reading Combos...");
22050 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22051 combosread=true;
22052 checkstatus(ret);
22053 box_out("okay.");
22054 box_eol();
22055
22056 //color data
22057 box_out("Reading Color Data...");
22058 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22059 checkstatus(ret);
22060 box_out("okay.");
22061 box_eol();
22062
22063 //tiles
22064 box_out("Reading Tiles...");
22065 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22066 checkstatus(ret);
22067 box_out("okay.");
22068 box_eol();
22069
22070 //midis
22071 box_out("Reading Tunes...");
22072 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22073 checkstatus(ret);
22074 box_out("okay.");
22075 box_eol();
22076
22077 //cheat codes
22078 box_out("Reading Cheat Codes...");
22079 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22080 checkstatus(ret);
22081 box_out("okay.");
22082 box_eol();
22083
22084 //initialization data
22085 box_out("Reading Init. Data...");
22086 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22087 checkstatus(ret);
22088 box_out("okay.");
22089 box_eol();
22090
22091 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22092 {
22093 setupsubscreens();
22094
22095 for(int32_t i=0; i<MAXDMAPS; ++i)
22096 {
22097 int32_t type=DMaps[i].type&dmfTYPE;
22098 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22099 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22100 }
22101 }
22102
22103 box_out("Setting Up Default Sound Effects...");
22104
22105 if(keepall&&!get_bit(skip_flags, skip_sfx))
22106 setupsfx();
22107
22108 box_out("okay.");
22109 box_eol();
22110
22111 //player sprites
22112 box_out("Reading Custom Player Sprite Data...");
22113 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22114 checkstatus(ret);
22115 box_out("okay.");
22116 box_eol();
22117
22118 box_out("Setting Up Default Item Drop Sets...");
22119 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22120 box_out("okay.");
22121 box_eol();
22122 }
22123
22124 99 init_spritelists();
22125
22126 // check data
22127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(f)
22128 {
22129 99 pack_fclose(f);
22130 99 }
22131
22132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!oldquest)
22133 {
22134
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(exists(tmpfilename))
22135 {
22136 delete_file(tmpfilename);
22137 }
22138 99 }
22139
22140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if(fixffcs && combosread && mapsread)
22141 {
22142 for(int32_t i=0; i<map_count; i++)
22143 {
22144 for(int32_t j=0; j<MAPSCRS; j++)
22145 {
22146 for(int32_t m=0; m<32; m++)
22147 {
22148 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22149 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22150 }
22151 }
22152 }
22153 }
22154
22155
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 18 times.
99 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22156 {
22157 18 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22158 18 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22159 18 zinit.cont_heart=100;
22160 18 zinit.start_heart=zinit.hc;
22161 18 }
22162
22163 99 box_out("Done.");
22164 99 box_eol();
22165 99 box_end(false);
22166
22167 // if (keepall==true||!get_bit(skip_flags, skip_header))
22168
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_header))
22169 {
22170 99 memcpy(Header, &tempheader, sizeof(tempheader));
22171 99 }
22172
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22173 {
22174 99 ZI.copyFrom(tempzi);
22175 99 }
22176
22177
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_maps))
22178 {
22179 map_count=old_map_count;
22180 }
22181
22182
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_rules))
22183 {
22184 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22185 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22186 }
22187
22188
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
99 if(!keepall||get_bit(skip_flags, skip_midis))
22189 {
22190 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22191 }
22192
22193
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(deletefilename[0] && exists(deletefilename))
22194 {
22195 99 delete_file(deletefilename);
22196 99 }
22197
22198 //Debug FFCore.quest_format[]
22199 99 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22200 99 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22201 99 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22202 99 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22203 99 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22204 99 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22205 99 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22206 99 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22207 99 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22208 99 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22209 99 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22210 99 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22211 99 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22212 99 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22213 99 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22214 99 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22215 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22216 99 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22217 99 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22218 99 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22219 99 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22220 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22221 99 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22222 99 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22223 99 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22224 99 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22225 99 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22226 99 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22227 99 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22228 99 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22229 //Print metadata for versions under 2.10 here. Bleah.
22230
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if( FFCore.quest_format[vZelda] < 0x210 )
22231 {
22232 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22233
22234 switch(FFCore.quest_format[vZelda])
22235 {
22236 case 0x193:
22237 {
22238 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22239 }
22240 case 0x192:
22241 {
22242 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22243 }
22244 case 0x190:
22245 {
22246 zprint2("Last saved in ZC Editor Version: 1.90");
22247 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22248 else zprint2("\n");
22249 break;
22250 }
22251 case 0x188:
22252 {
22253 zprint2("Last saved in ZC Editor Version: 1.88");
22254 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22255 else zprint2("\n");
22256 break;
22257 }
22258 case 0x187:
22259 {
22260 zprint2("Last saved in ZC Editor Version: 1.87");
22261 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22262 else zprint2("\n");
22263 break;
22264 }
22265 case 0x186:
22266 {
22267 zprint2("Last saved in ZC Editor Version: 1.86");
22268 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22269 else zprint2("\n");
22270 break;
22271 }
22272 case 0x185:
22273 {
22274 zprint2("Last saved in ZC Editor Version: 1.85");
22275 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22276 else zprint2("\n");
22277 break;
22278 }
22279 case 0x184:
22280 {
22281 zprint2("Last saved in ZC Editor Version: 1.84");
22282 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22283 else zprint2("\n");
22284 break;
22285 }
22286 case 0x183:
22287 {
22288 zprint2("Last saved in ZC Editor Version: 1.83");
22289 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22290 else zprint2("\n");
22291 break;
22292 }
22293 case 0x182:
22294 {
22295 zprint2("Last saved in ZC Editor Version: 1.82");
22296 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22297 else zprint2("\n");
22298 break;
22299 }
22300 case 0x181:
22301 {
22302 zprint2("Last saved in ZC Editor Version: 1.81");
22303 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22304 else zprint2("\n");
22305 break;
22306 }
22307 case 0x180:
22308 {
22309 zprint2("Last saved in ZC Editor Version: 1.80");
22310 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22311 else zprint2("\n");
22312 break;
22313 }
22314 default:
22315 {
22316 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22317 }
22318 }
22319 }
22320
22321 99 return qe_OK;
22322
22323 invalid:
22324 box_out("error.");
22325 box_eol();
22326 box_end(true);
22327
22328 if(f)
22329 {
22330 pack_fclose(f);
22331 }
22332
22333 if(!oldquest)
22334 {
22335 if(exists(tmpfilename))
22336 {
22337 delete_file(tmpfilename);
22338 }
22339
22340 if(deletefilename[0] && exists(deletefilename))
22341 {
22342 delete_file(deletefilename);
22343 }
22344 }
22345
22346 return qe_invalid;
22347
22348 99 }
22349
22350 99 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22351 {
22352 99 loading_qst_name = filename;
22353 99 loading_qst_num = qst_num;
22354 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22355 // So to avoid a more-recently update .qst file from hitting the "last saved in a newer version" prompt, we disable for replaying.
22356
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (!replay_is_replaying())
22357 loadquest_report = report;
22358 99 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22359 99 load_tmp_zi = NULL;
22360 99 loading_qst_name = NULL;
22361 99 loadquest_report = false;
22362 99 loading_qst_num = 0;
22363 99 return ret;
22364 }
22365 /*** end of qst.cc ***/
22366
22367